hdu 4504(背包最优方案数)
来源:互联网 发布:linux如何设置双屏显示 编辑:程序博客网 时间:2024/05/29 06:36
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4504
View 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(3.0,count);13 return ;14 }else {15 dfs(a+3,b,count-1);16 dfs(a+2,b,count-1);17 dfs(a+1,b,count-1);18 }19 }20 21 int main(){22 int a,b,time;23 while(~scanf("%d%d%d",&a,&b,&time)){24 _count=0;25 if(time<15&&a<=b){26 printf("0\n");27 }else {28 int count1=1+(time-15)/30;29 int count2=(time-15)/30;30 b+=count2;31 if(a+2*count1<b){32 printf("0\n");33 }else if((b-a)<count1){34 printf("%d\n",pow(3.0,count1));35 }else {36 dfs(a,b,count1);37 printf("%d\n",_count);38 }39 }40 }41 return 0;42 }43 */44 45 #include<iostream>46 #include<cstring>47 using namespace std;48 49 __int64 dp[24][77];//dp[i][j]表示第i次进攻后我方得分j(不算上原来的分数)时的最多方案数50 51 void Initiate(){52 memset(dp,0,sizeof(dp));53 //最多进攻20次,最多得分为60.54 dp[1][1]=dp[1][2]=dp[1][3]=1;55 for(int i=1;i<=20;i++){56 for(int j=1;j<=60;j++){57 if(j>1)dp[i][j]+=dp[i-1][j-1];58 if(j>2)dp[i][j]+=dp[i-1][j-2];59 if(j>3)dp[i][j]+=dp[i-1][j-3];60 }61 }62 }63 64 int main(){65 Initiate();66 int a,b,time;67 while(~scanf("%d%d%d",&a,&b,&time)){68 int count=time/15;69 int count1=(count+1)/2;70 int count2=count-count1;71 if(count1==0){72 if(a>b)printf("1\n");73 else printf("0\n");74 continue;75 }76 b+=count2;77 int tmp=(b-a)+1;78 if(tmp<0)tmp=0;79 __int64 ans=0;80 for(int i=tmp;i<=count1*3;i++){81 ans+=dp[count1][i];82 }83 printf("%I64d\n",ans);84 }85 return 0;86 }
0 0
- hdu 4504(背包最优方案数)
- hdu 4504 背包最优方案数
- HDU 4504 威威猫系列故事——篮球梦(背包最优方案数)
- HDU-2126 Buy the souvenirs (记录最优方案数的01背包问题 入门题)
- 求背包方案总数,最优背包方案数
- HDU 2126(01背包扩展,记录方案数)
- hdu 2126 DP 方案数背包
- 背包问题--输出最优方案
- UVa 674 Coin Change (完全背包&最优解的方案数)
- hdu 2126 Buy the souvenirs(求方案数的背包)
- hdu 2126 Buy the souvenirs(求方案数的背包)
- hdu 2126 Buy the souvenirs (01背包输出方案数)
- HDU 2126 Buy the souvenirs 01背包 输出方案数
- HDU 1284钱币兑换问题 完全背包求方案数
- hdu 2126 (背包问题之求方案数)
- 背包问题的方案数(01)
- 背包问题----完全背包(最优方案总数分析及实现)
- 记录最优解的方案数
- hdu 2116(判断是否溢出)
- hdu 1725(Find minimal sum)
- hdu 2188
- ListView去掉自带的线条和滚动条
- hdu 4501(背包)
- hdu 4504(背包最优方案数)
- hdu 4502
- hdu 4508(完全背包)
- hdu 4509(memset标记)
- hdu 4506(快速幂)
- hdu 2176+hdu 2147
- Dubbo zookeeper 初探(1)
- hdu 2136(最大素数因子)
- hdu 2501