HDU's ACM 2110 Crisis of HDU
来源:互联网 发布:sqlserver count if 编辑:程序博客网 时间:2024/05/16 01:00
原题链接:HDU's ACM 2110 Crisis of HDU
分析:又一道母函数题目,可参考HDU's ACM 1028 Ignatius and the Princess III,思路类似,不同之处在于系数与指数由pi,mi指定。
AC Code:
<span style="font-family:Microsoft YaHei;font-size:14px;">#include <stdio.h>#include <string.h>#define MAXN 10000#define NUM_MAX 105int coeff1[MAXN];int coeff2[MAXN];int p[NUM_MAX];int m[NUM_MAX];int main(){int n;int i, j, k, end;int sum, target;while(scanf("%d", &n) == 1 && n) {sum = 0;for(i=0;i<n;++i) {scanf("%d%d", &p[i], &m[i]);sum += p[i]*m[i];}if(sum%3){printf("sorry\n");continue;}target = sum/3;memset(coeff1, 0, sizeof(coeff1));memset(coeff2, 0, sizeof(coeff2));end = p[0]*m[0];for(i=0;i<=end && i<=target;i+=p[0])coeff1[i] = 1;for(i=1;i<n;++i){end = p[i]*m[i];for(j=0;j<=target;++j)for(k=0;k<=end;k+=p[i]){if(j+k>target)break;coeff2[j+k] += coeff1[j];}for(j=0;j<=target;++j){coeff1[j] = coeff2[j]%10000;coeff2[j] = 0;}}if(coeff1[target])printf("%d\n", coeff1[target]);elseprintf("sorry\n");}return 0;}</span>
0 0
- HDU's ACM 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(母函数)
- 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
- hdu2110-Crisis of HDU
- Crisis of HDU
- Crisis of HDU
- Crisis of HDU
- 黑马程序员——JDK5特性、正则 笔记第十二篇
- Struts2中访问HttpServletRequest和HttpSession
- Linux开机启动十步骤
- 七万冠名鬼脚七,到底值不值?
- poj 1195 Mobile phones(二维树状数组)
- HDU's ACM 2110 Crisis of HDU
- Android之NDK编码转(UTF8->GBK)
- Oracle数据库的下载,安装(windows 32bit)
- 数据连接池JNDI
- 题目1072:有多少不同的面值组合? 题目1074:对称平方数 题目1075:斐波那契数列 题目1076:N的阶乘
- JAVA程序设计(16)----- 贪食蛇游戏制作 LinkedList 初级应用
- Swift Enum与Switch
- Hibernate环境搭建第一个小程序
- 类,对象,访问控制符