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

题意:分出1/3的价值,有几种可能?

思路:母函数

与之前的题目2079相似,复习笔记再来写代码:

https://www.cnblogs.com/CheeseIce/p/9595315.html

代码:

#include <iostream>
#include <cstring>
using namespace std; #define min(a,b) ((a)<(b)?(a):(b)) int N,n[],v[],i,last,last2,sum;
int a[],b[]; int main()
{
while ((cin>>N)&&N!=)
{
sum=;
for (i=;i<N;i++)
{
cin>>v[i]>>n[i];
sum+=v[i]*n[i];
}
if (sum%!=)
{
cout<<"sorry"<<endl;
continue;
}
sum/=;
a[]=;
last=;
int j,k;
for (i=;i<N;i++)
{
last2=min(last+n[i]*v[i],sum);
memset(b,,sizeof(int)*(last2+));
for (j=;j<=n[i]&&j*v[i]<=last2;j++)
for (k=;k<=last&&k+j*v[i]<=last2;k++)
{
b[k+j*v[i]]+=a[k];
b[k+j*v[i]]%=;
}
memcpy(a,b,sizeof(int)*(last2+));
last=last2;
}
if (a[sum]>)
cout<<a[sum]<<endl;
else
cout<<"sorry"<<endl;
}
}

2110 ACM Crisis of HDU 母函数的更多相关文章

  1. Crisis of HDU(母函数)

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

  2. HDU 2110 Crisis of HDU

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

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

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

  4. hdu_2110_Crisis of HDU(母函数)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2110 题意:给你N个价值和数目,求方案数,很裸的母函数. #include<cstdio> ...

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

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

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

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

  7. 『ACM C++』HDU杭电OJ | 1415 - Jugs (灌水定理引申)

    今天总算开学了,当了班长就是麻烦,明明自己没买书却要带着一波人去领书,那能怎么办呢,只能说我善人心肠哈哈哈,不过我脑子里突然浮起一个念头,大二还要不要继续当这个班委呢,既然已经体验过就可以适当放下了吧 ...

  8. ACM学习历程—HDU 3915 Game(Nim博弈 && xor高斯消元)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3915 题目大意是给了n个堆,然后去掉一些堆,使得先手变成必败局势. 首先这是个Nim博弈,必败局势是所 ...

  9. ACM学习历程—HDU 5536 Chip Factory(xor && 字典树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5536 题目大意是给了一个序列,求(si+sj)^sk的最大值. 首先n有1000,暴力理论上是不行的. ...

随机推荐

  1. vue 中动态绑定class 和 style的方法

    先列举一些例子 :class="['content',{'radioModel':checkType}]" :class="['siteAppListDirNode',{ ...

  2. Python游戏编程(Pygame)

    安装Pygame pip install pygame C:\Users> pip install pygame Collecting pygame Downloading https://fi ...

  3. spring cloud 创建一个简单Eureka Server

    在Spring Cloud实现一个Eureka Server是一件非常简单的事情.下面我们来写一个Eureka Server DEMO. 编码 父项目pom.xml <?xml version= ...

  4. .net C# 抽奖,中奖

    demo设置了8个奖项,每个奖项可以自定义中奖率,精度为1/10000 public string PrizeDraw() { //奖品以及中奖率 const string prizeString = ...

  5. Kubeadm安装的K8S集群1年证书过期问题的解决思路

    这个问题,很多使用使用kubeadm的用户都会遇到. 网上也有类似的帖子,从源代码编译这种思路, 在生产环境,有些不现实. 还是使用kubeadm的命令操作,比较自然一点. 当然,自行生成一套证书,也 ...

  6. 一脸懵逼搭建Zookeeper分布式集群

    1:首先将http://zookeeper.apache.org/ 下载好的zookeeper-3.4.5.tar.gz上传到三台虚拟机上,之前博客搭建好的(安装Zookeeper之前记得安装好你的j ...

  7. google 插件

    鼠标手势    crxMouse Chrome™ Gestures Google翻译 json格式化  JSONView github展开文件夹     Octotree axure 原型  Axur ...

  8. 【Android】Android取消EditText自动获取焦点

    解决方法: 在EditText的父级控件中找一个,设置成 android:focusable="true" android:focusableInTouchMode="t ...

  9. input标签checkbox选中触发事件的方法

    1.方法一 <input type="checkbox" onclick="checkboxOnclick(this)" /> <script ...

  10. 2018牛客网暑假ACM多校训练赛(第五场)F take 树状数组,期望

    原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round5-F.html 题目传送门 - https://www.no ...