题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2110

题意:给你N个价值和数目,求方案数,很裸的母函数。

 #include<cstdio>
int c1[],c2[],all,pi[],mi[],su,i,j,k;
int mu(int sum){
for(i=;i<=sum;i++)c1[i]=,c2[i]=;
for(i=;i<=mi[];i++)c1[pi[]*i]=;
for(i=;i<=all;i++){
for(j=;j<=mi[i];j++)
for(k=;pi[i]*j+k<=sum;k++)c2[pi[i]*j+k]+=c1[k]%;
for(j=;j<=sum;j++)c1[j]=c2[j]%,c2[j]=;
}
return c1[sum];
}
int main(){
while(~scanf("%d",&all),all){
for(i=,su=;i<=all;i++)scanf("%d%d",&pi[i],&mi[i]),su+=pi[i]*mi[i];
if(su%)puts("sorry");
else printf("%d\n",mu(su/));
}
return ;
}

hdu_2110_Crisis of HDU(母函数)的更多相关文章

  1. HDU1171——Big Event in HDU(母函数)

    Big Event in HDU DescriptionNowadays, we all know that Computer College is the biggest department in ...

  2. 2110 ACM Crisis of HDU 母函数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2110 题意:分出1/3的价值,有几种可能? 思路:母函数 与之前的题目2079相似,复习笔记再来写代码: ...

  3. Big Event in HDU (母函数, 玄学AC)

    Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't k ...

  4. HDU 1171 Big Event in HDU 母函数

    欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory ...

  5. HDU 2110-Crisis of HDU(母函数)

    Crisis of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) To ...

  6. Big Event in HDU(HDU1171)可用背包和母函数求解

    Big Event in HDU  HDU1171 就是求一个简单的背包: 题意:就是给出一系列数,求把他们尽可能分成均匀的两堆 如:2 10 1 20 1     结果是:20 10.才最均匀! 三 ...

  7. 组合数学 - 母函数的变形 --- hdu 1171:Big Event in HDU

    Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  8. 组合数学 - 母函数的运用 + 模板 --- hdu : 2082

    找单词 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  9. HDU 2065 “红色病毒”问题 --指数型母函数

    这种有限制的类棋盘着色问题一般可以用指数型母函数来解决,设Hn表示这样的着色数,首先H0=1,则Hn等于四个字母的(A,B,C,D)的多重集合的n排列数,其中每个字母的重数是无穷,且要求A,C出现的次 ...

随机推荐

  1. 关于requirejs中的define的原理理解

    我们已经了解到模块模式是为单例创建私有变量和特权方法的. 一个最基本的例子: var foo=(function(){ var something='cool', var another=[1,2,3 ...

  2. iOS开发自定义流水布局

    //集成UICollectionViewFlowLayout 自己写的布局 //  SJBFlowLayout.m //  自定义流水布局 // //  Created by zyyt on 16/7 ...

  3. ZOJ Martian Addition

    Description In the 22nd Century, scientists have discovered intelligent residents live on the Mars. ...

  4. Entity Framework Code First -- Migrations 迁移

    在开始使用迁移(Migrations)之前,我们需要一个 Project 和一个 Code First Model, 对于本文将使用典型的 Blog 和 Post 模型 创建一个新的控制台应用程序 M ...

  5. treeview自动从表中添加标题和列值做目录的方法2

    treeview自动从表中添加标题和列值做目录的方法2,该方法是借鉴万一老师的 http://www.cnblogs.com/del/archive/2008/05/15/1114450.html 首 ...

  6. 关于开启url的pathinfo模式

    1.apache要开启pathinfo模式,需要在 <Directory /> Options +Indexes +FollowSymLinks +ExecCGI AllowOverrid ...

  7. Gentoo解决Udev升级的网卡重命名问题

    问题描述: 配置网络时,很多新手运行ifconfig命令查看网卡时,会发现我们熟悉的eth0网卡没有了,或是发现一些不规则命名的东东,不错,那就是你的网卡. 因为内核升级(忘记具体哪个版本了)从ude ...

  8. PHP input 显示html 元素

    使用函数 htmlspecialchars ,转换保存的html源码,前台使用转换后的变量.

  9. ios navigationController代码创建

    1.新建类文件FirstViewController,subClass of:UIViewController 2.新建类文件MYNavigationController,subClass of:UI ...

  10. SharePoint 网站登录不上,3次输入用户名/密码白页、

    来源于:http://www.cnblogs.com/jianyus/p/3249091.html 新搭建的SharePoint 2013环境,第一次干的这么憋屈的慌,先是接了一个Ghost的服务器, ...