上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 61 下一页
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4472思路:每次都要把那个终极boss除去,然后dp[i]=sum{dp[j]}((i-1)%j==0);原因:根据题意,一个节点一定要用去做树根,所以剩下i-1个点,这i-1个节点把它分成几份,这几份完全相同,其本身强烈对称,然后不断更新就行了。。。orzView Code 1 #include<iostream> 2 const int N=1010; 3 const int MOD=1e9+7; 4 using namespace std; 5 int dp[N]; 6 7 voi 阅读全文
posted @ 2013-03-24 11:15 ihge2k 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4517昨天Tencent的题目,好吧,当时悲剧地TLE了。。。。orz,今天网上搜了一下,基本上都是用dp做的。。。orz。。。思路:sum[i][j]表示从1-i,1-j的矩阵中的'*'的个数。。。View Code 1 #include<iostream> 2 const int N=2004; 3 using namespace std; 4 char map[N][N]; 5 int sum[N][N];//sum[i][j]表示从1-i,1-j的矩形中的&quo 阅读全文
posted @ 2013-03-24 09:41 ihge2k 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1133卡特兰数的应用:(C(m+n,n)-C(m+n,m+1))*m!*n!化简即(m+n)!*(m-n+1)/(m+1)string处理比较方便。。。View Code 1 #include<iostream> 2 #include<algorithm> 3 #include<string> 4 #include<vector> 5 using namespace std; 6 vector<string>vet; 7 8 string 阅读全文
posted @ 2013-03-23 17:30 ihge2k 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2189思路:dp[i][j]表示用最大不超过i的素数组成整数j的最多的方法。1、若i不是素数,则dp[i][j]=dp[i-1][j];2、否则,dp[i][j]=d[i-1][j]+dp[i][j-i];View Code 1 #include<iostream> 2 #include<cmath> 3 #include<cstring> 4 const int N=170; 5 using namespace std; 6 int prime[N]; 7 in 阅读全文
posted @ 2013-03-23 14:26 ihge2k 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4514Tencent昨天比赛的题目,昨天看的时候没什么思路,今天在网上搜了一下,说是可以用并查集做。。。果然,过了。。。看来还是做的题不够多啊!!!思路:并查集判环,并把每次的边权值都加到根结点的上去,最后求每个根结点权值的最大值就行了。。。orzView Code 1 #include<iostream> 2 #include<cstring> 3 const int N=100007; 4 using namespace std; 5 struct Edge{ 6 int 阅读全文
posted @ 2013-03-23 10:17 ihge2k 阅读(1002) 评论(2) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2519原来可以有递推公式的。。。c[n][m]=c[n-1][m]+c[n-1][m-1];orz。。。自己搞了个阶乘。。。orz。。。还用string来处理了。。小题大做了。。。View Code 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 vectorvet; 7 8 string facs(const string &str,int num){ 9 int len=str.size();1.. 阅读全文
posted @ 2013-03-22 23:01 ihge2k 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2501递推题:dp[i]=dp[i-1]+dp[i-2]*2(i>=3);View Code 1 #include<iostream> 2 using namespace std; 3 int dp[40]; 4 5 int main(){ 6 dp[0]=0,dp[1]=1,dp[2]=3; 7 for(int i=3;i<=31;i++){ 8 dp[i]=dp[i-1]+dp[i-2]*2; 9 }10 int _case;11 sc... 阅读全文
posted @ 2013-03-22 21:28 ihge2k 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2136求某个数最大素数因子的位置。View Code 1 #include<iostream> 2 const int MAXN=1000004; 3 using namespace std; 4 bool prime[MAXN]; 5 int res[MAXN];//res[j]存放j的最大素数因子的位置,即答案 6 7 int main(){ 8 int count=1; 9 for(int i=2;i<MAXN;i++){10 if(!prime[i]){1... 阅读全文
posted @ 2013-03-22 19:48 ihge2k 阅读(371) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2147直接猜的。。。View Code 1 #include<iostream> 2 using namespace std; 3 4 int main(){ 5 int n,m; 6 while(~scanf("%d%d",&n,&m)&&n&&m){ 7 if(n%2&&m%2){ 8 printf("What a pity!\n"); 9 }else 10 printf(&quo 阅读全文
posted @ 2013-03-22 17:57 ihge2k 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4506一开始不知道如何下手,后来网上看别人说是用快速幂做。。。各人觉得tencent的题出的挺不错的。。。View Code 1 #include<iostream> 2 #include<cmath> 3 const int MOD=1e9+7; 4 const int N=10100; 5 using namespace std; 6 __int64 num[N]; 7 8 //快速幂 9 __int64 pow(__int64 k,__int64 t){10 if(k= 阅读全文
posted @ 2013-03-22 16:34 ihge2k 阅读(170) 评论(0) 推荐(0) 编辑
上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 61 下一页