【Hdu】1085 Holding Bin-Laden Captive!
来源:互联网 发布:ubuntu 系统安装 编辑:程序博客网 时间:2024/05/01 23:04
【分析】
生成函数第一道~
设生成函数为G(x)=(1+x+x^2+...+x^n[0])(1+x^2+x^4+...+x^n[2])(1+x^5+x^10+...+x^n[3])。
然后多项式展开,再用线性扫一遍。
生成函数第一道~
设生成函数为G(x)=(1+x+x^2+...+x^n[0])(1+x^2+x^4+...+x^n[2])(1+x^5+x^10+...+x^n[3])。
然后多项式展开,再用线性扫一遍。
【代码】
<span style="font-size:18px;">#include <cstdio>#include <cstring>#include <cstdlib>using namespace std;const int W=8010;const int d[3]={1,2,5};int t[W],v[W],n[3];inline int read(void){int s=0,f=1; char c=getchar();for (;c<'0'||c>'9';c=getchar()) if (c=='-') f=-1;for (;'0'<=c&&c<='9';c=getchar()) s=(s<<1)+(s<<3)+c-'0';return s*f;}int main(void){for (int c=1;c;){for (int i=0;i<3;i++) n[i]=read();if (!n[0]&&!n[1]&&!n[2]) break;memset(v,0,sizeof v); v[0]=1;for (int i=0;i<3;i++){memset(t,0,sizeof t);for (int j=0;j<=W;j++)for (int k=0;k<=n[i]&&j+k*d[i]<=W;k++)t[j+k*d[i]]+=v[j];for (int j=0;j<=W;j++) v[j]=t[j],t[j]=0;}for (int i=0;i<=W;i++)if (!v[i]) {printf("%d\n",i);break;}}return 0;}</span>
0 0
- hdu 1085 Holding Bin-Laden Captive!
- HDU 1085 - Holding Bin-Laden Captive!
- HDU 1085 Holding Bin-Laden Captive!
- HDU 1085 Holding Bin-Laden Captive
- HDU 1085 Holding Bin-Laden Captive!
- Hdu 1085 - Holding Bin-Laden Captive!
- hdu 1085 Holding Bin-Laden Captive!
- hdu 1085 Holding Bin-Laden Captive!
- hdu 1085 Holding Bin-Laden Captive!
- hdu 1085 Holding Bin-Laden Captive!
- hdu 1085 Holding Bin-Laden Captive!
- hdu 1085 Holding Bin-Laden Captive!
- hdu 1085 Holding Bin-Laden Captive!
- Holding Bin-Laden Captive! hdu 1085
- hdu/hdoj 1085 Holding Bin-Laden Captive!
- hdu 1085 Holding Bin-Laden Captive!
- hdu 1085 Holding Bin-Laden Captive!
- HDU 1085 Holding Bin-Laden Captive!
- 怎么用CIFilter给图片加上各种各样的滤镜_1
- 整数类型
- Codeforces Round #310 (Div. 1)A B
- hadoop常用命令
- 虚拟内存VS物理内存
- 【Hdu】1085 Holding Bin-Laden Captive!
- Pascal's Triangle
- modbus TCP IP功能码及报文解析
- [Leetcode]-Remove Duplicates from Sorted Array
- linux系统头文件
- mysql relay_log_info_repository和master_info_repository
- Eclipse 中的GitHub插件
- iOS中避免类的循环引用和协议一起使用
- 【C/C++相关】论程序员写技术博客的重要性