摘要: 题目链接: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) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4509memset标记,挺不错的方法。。View Code 1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 5 6 int main(){ 7 int n; 8 while(~scanf("%d",&n)){ 9 int time[1440];10 int sh,eh,sm,em;11 memset(time,1,sizeof(time));//一... 阅读全文
posted @ 2013-03-22 15:01 ihge2k 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4508一开始还以为是一个01背包呢。。。看了第二组测试数据之后就发现是完全背包了。。。View Code 1 #include<iostream> 2 const int N=110; 3 using namespace std; 4 int dp[N*N*10]; 5 struct Node{ 6 int a,b; 7 }node[N]; 8 9 int main(){10 int n;11 while(~scanf("%d",&n)){12 for(i.. 阅读全文
posted @ 2013-03-22 11:11 ihge2k 阅读(762) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4502dp[i]表示前i天的最大收入。View Code 1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 const int N=110; 5 using namespace std; 6 int dp[N];//dp[i]表示前i天的最大收入 7 8 struct Node{ 9 int start,end;10 int value;11 }node[N*10];12 13 int 阅读全文
posted @ 2013-03-22 09:55 ihge2k 阅读(347) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4504View Code 1 /* 2 #include<iostream> 3 #include<cmath> 4 using namespace std; 5 int _count=0; 6 7 void dfs(int a,int b,int count){ 8 if(count==0){ 9 if(a>b)_count++;10 return ;11 }else if((b-a)<count){12 _count+=pow(... 阅读全文
posted @ 2013-03-22 09:17 ihge2k 阅读(437) 评论(0) 推荐(0) 编辑