Hdu 2110 Crisis of HDU 母函数
来源:互联网 发布:制作蹭饭地图软件 编辑:程序博客网 时间:2024/05/16 05:38
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2110
题目大意:给出物品种类数及每种物品的个数及价值,和需要组合出的数
代码如下:
#include <stdio.h>#include <string.h>const int MAX=10005;int c1[MAX],c2[MAX];int main(){ int T,v[102],num[102];//v为价值,num为数量,和硬币问题类似 while(scanf("%d",&T)&&T) { int sum=0; for(int i=1; i<=T; i++) { scanf("%d%d",&v[i],&num[i]); sum+=v[i]*num[i]; } if(sum%3!=0) { printf("sorry\n"); continue; } sum/=3; memset(c1,0,sizeof(c1)); c1[0]=1; for(int i=1; i<=T; i++)//循环每个因子 { memset(c2,0,sizeof(c2)); for(int j=0; j<=num[i]&&j*v[i]<=sum; j++)//每个因子的每一项 { for(int k=0; k+j*v[i]<=sum; k++)//循环c1数组的每一项 c2[k+j*v[i]] += c1[k],c2[k+j*v[i]]%=10000;//呵呵,感觉按照题意最大值应该不会超过10000 } //因此感觉不用取模,但是不取模就wa memcpy(c1,c2,sizeof(c2)); } if(c1[sum]) printf("%d\n",c1[sum]); else printf("sorry\n"); } return 0;}
0 0
- hdu 2110 Crisis of HDU(母函数)
- HDU 2110 Crisis of HDU 母函数
- Hdu 2110 Crisis of HDU 母函数
- HDU 2110 Crisis of HDU 母函数
- hdu 2110 Crisis of HDU(母函数)
- HDU 2110-Crisis of HDU(母函数)
- HDU 2110 Crisis of HDU 【母函数】
- Crisis of HDU 2110 (母函数)
- HDOJ-2110 Crisis of HDU(母函数)
- HDOJ--2110Crisis of HDU!母函数
- Crisis of HDU+母函数
- HDU 2110 Crisis of HDU (母函数问题)
- hdu 2110 Crisis of HDU(母函数)
- HDU2110 Crisis of HDU【母函数】
- Crisis of HDU 还是母函数
- Crisis of HDU(hdu2110)母函数
- HDU-2110 Crisis of HDU
- HDU 2110 Crisis of HDU
- 反斜杠加3个数字是什么编码, JAVA转义序列, 转义字符汇总
- js技术
- 结对学发音
- 将Throwable的信息转换为字符串
- win7添加防火墙例外的程序和端口
- Hdu 2110 Crisis of HDU 母函数
- 递归处理多层嵌套列表
- 分享一个新的对字符串的哈希算法之FastHash
- 基于coocs2d-x quick 的图形填充
- linux tftp创建
- android ,点击title的ImageView弹出PopupWindow
- Nutch-2.2.1----过滤抓取数据
- Android中如何使用ViewPager实现类似laucher左右拖动效果
- 超级新手第一次修饰代码 不知道规范吗?请高手评价,谢谢了,