题目: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. linux安装MongoDB

    安装 32bit的mongodb最大只能存放2G的数据,64bit就没有限制 到官网,选择合适的版本下载,本次下载3.4.0版本 解压 tar -zxvf mongodb-linux-x86_64-u ...

  2. sass方式实现颜色平铺(红色--->紫色)

    <!DOCTYPE html><html lang="en"><head> <link rel="stylesheet" ...

  3. meaven

    一个项目管理工具.java语言编写的,所以可以跨平台 https://mvnrepository.com/

  4. python练习册0006

    第 0006 题:你有一个目录,放了你一个月的日记,都是 txt,为了避免分词的问题,假设内容都是英文,请统计出你认为每篇日记最重要的词. import re import os def get_li ...

  5. UIDebuggingInformationOverlay 调试

    https://archimboldi.me/posts/%E7%BF%BB%E8%AF%91-uidebugginginformationoverlay.html http://ryanipete. ...

  6. 关于K8S证书生成方面的脚本草稿

    周日在家里计划的. 俺不加班,但在家学习的时间一样没少! 还没弄完,只粗粗弄了etcd证书. #! /usr/bin/env bash set -e set -u set -x THIS_HOST=$ ...

  7. NLS_CHARACTERSET和NLS_NCHAR_CHARACTERSET

    The NLS_CHARACTERSET is used for CHAR, VARCHAR2, LONG and CLOB columns;The NLS_NCHAR_CHARACTERSET is ...

  8. python的paramiko模块

        paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接.paramiko支持Linux, Solaris, BSD, MacOS X, ...

  9. Flink--基于mysql的sink和source

    基于mysql的source操作 object MysqlSource { def main(args: Array[String]): Unit = { val env = StreamExecut ...

  10. iis url rewrite http->https non-www->www

    <system.webServer> <rewrite> <rules> <rule name="Redirect abc.com to www&q ...