poj 3181 Dollar Dayz(完全背包)
来源:互联网 发布:宾得 知乎 编辑:程序博客网 时间:2024/04/28 06:45
要用大数。。
#include <stdio.h>#include <string.h>#define max(a,b) (a)>(b)?(a):(b)struct BigInt{ const static int mod = 10000; const static int DLEN = 4; int a[100],len; BigInt() { memset(a,0,sizeof(a)); len = 1; } void set(int v) { memset(a,0,sizeof(a)); len = 0; do { a[len++] = v%mod; v /= mod; } while(v); } BigInt operator +(const BigInt &b)const { BigInt res; res.len = max(len,b.len); for(int i = 0; i <= res.len; i++) res.a[i] = 0; for(int i = 0; i < res.len; i++) { res.a[i] += ((i < len)?a[i]:0)+((i < b.len)?b.a[i]:0); res.a[i+1] += res.a[i]/mod; res.a[i] %= mod; } if(res.a[res.len] > 0)res.len++; return res; } void output() { printf("%d",a[len-1]); for(int i = len-2; i >=0 ; i--) printf("%04d",a[i]); printf("\n"); }};const int MAXN = 1010;BigInt dp[MAXN];int w[110];int N,K;int main(){ scanf("%d %d",&N,&K); for(int i = 0; i < K; ++i) w[i] = i+1; dp[0].set(1); for(int i = 0; i < K; ++i) { for(int j = w[i]; j <= N; ++j) { dp[j] = dp[j] + dp[j-w[i]]; } } dp[N].output(); return 0;}
阅读全文
0 0
- POJ 3181 Dollar Dayz (完全背包)
- poj 3181 Dollar Dayz 高精度+完全背包
- poj 3181 Dollar Dayz dp 完全背包
- POJ 3181 Dollar Dayz(高精度完全背包)
- poj 3181 Dollar Dayz(完全背包)
- POJ 3181 Dollar Dayz 完全背包 + 高精度
- POJ 3181 Dollar Dayz(完全背包+大数)
- poj 3181 Dollar Dayz(完全背包)
- poj Dollar Dayz(完全背包)
- poj 3181 Dollar Dayz (完全背包+高精度)
- POJ 3181 Dollar Dayz 01完全背包问题
- POJ 3181 - Dollar Dayz(完全背包+高精度)
- POJ 3181 Dollar Dayz(完全背包+简单高精度加法)
- POJ 题目3181 Dollar Dayz(完全背包,技巧)
- poj Dollar Dayz 3181 (DP&完全背包) 好题
- Dollar Dayz POJ - 3181 dp,完全背包,简单高精度加法
- POJ--3181--Dollar Dayz--背包/高精度
- POJ - 3181 Dollar Dayz(多重背包)
- 一个简易的网页抽奖程序
- 【软工学习】第十四章——数据结构与算法
- 《笨办法学python》加分习题12——我的答案
- mcs的文件格式
- NodeJs 生成验证码
- poj 3181 Dollar Dayz(完全背包)
- pthread_cond_t
- 练习18
- Android开发初级00_1如何在安卓开发中使用数据库之量框架LitePal
- SSM时jdbc报错 Cannot create PoolableConnectionFactory (The server time zone value '�й���ʱ��' is unreco
- Gym 101341G I love Codeforces 模拟
- js事件绑定 监听
- 无线路由器桥接——手机连不上网
- 棋盘问题(NOIP1997)