hdu 1085 http://acm.hdu.edu.cn/showproblem.php?pid=1085
2012-11-07 09:13
330 查看
#include<stdio.h> #include<string.h> #define max 8010 int c1[max],c2[max];//c1和c2的坐标代表指数的大小 c1与c2里面存的是该指数的系数。 int main()//c1存的是前一个多项式的属性 c2存的是后一个多项式的属性 需要不断更新 模拟多项式的乘法运算。 { int num[4]; int sumNum; int test[4]= {1,2,5}; while(scanf("%d%d%d",&num[0],&num[1],&num[2])!=EOF) { if(num[0]==0&&num[1]==0&&num[2]==0) break; memset(c1,0,sizeof(c1)); memset(c2,0,sizeof(c2)); sumNum=test[0]*num[0]; for(int i=0; i<=sumNum; i++) { c1[i]=1; c2[i]=0; } for(int i=1; i<3; i++) { sumNum+=test[i]*num[i]; for(int j=0; j<=sumNum; j++) { for(int k=0; k+j<=sumNum; k+=test[i]) { c2[k+j]+=c1[j]; } } for(int i=0; i<=sumNum; i++) { c1[i]=c2[i]; c2[i]=0; } } int pox; //for(pox=1;pox<=20;pox++) //printf("%d\n",c1[pox]); for(pox=1; pox<=max; pox++) if(c1[pox]==0) break; printf("%d\n",pox); } return 0; }
相关文章推荐
- http://acm.hdu.edu.cn/showproblem.php?pid=1722
- http://acm.hdu.edu.cn/showproblem.php?pid=1299 (求因子个数)
- http://acm.hdu.edu.cn/showproblem.php?pid=2674 (很神奇)
- http://acm.hdu.edu.cn/showproblem.php?pid=1166 更新节点,区间求和
- http://acm.hdu.edu.cn/showproblem.php?pid=2227 dp + 线段树
- http://acm.hdu.edu.cn/showproblem.php?pid=1823 二维线段树
- http://acm.hdu.edu.cn/showproblem.php?pid=1003
- http://acm.hdu.edu.cn/showproblem.php?pid=1506
- hdu http://acm.hdu.edu.cn/showproblem.php?pid=1584 蜘蛛牌
- http://acm.hdu.edu.cn/showproblem.php?pid=1789 很好的贪心题目
- http://acm.hdu.edu.cn/showproblem.php?pid=2717,有所借鉴哦!!
- http://acm.hdu.edu.cn/showproblem.php?pid=4512
- 完数 &&http://acm.hdu.edu.cn/showproblem.php?pid=1406
- Number Sequence(http://acm.hdu.edu.cn/showproblem.php?pid=1005)
- 士兵队列训练问题http://acm.hdu.edu.cn/showproblem.php?pid=1276
- http://acm.hdu.edu.cn/showproblem.php?pid=1709
- http://acm.hdu.edu.cn/showproblem.php?pid=1333
- http://acm.hdu.edu.cn/showproblem.php?pid=1108 java BIgInteger gcd
- http://acm.hdu.edu.cn/showproblem.php?pid=2136
- HDU 1702 http://acm.hdu.edu.cn/showproblem.php?pid=1702