您的位置:首页 > 其它

[luoguP1474] 货币系统 Money Systems(背包)

2017-06-20 15:18 183 查看

传送门

 

背包

 

——代码

#include <cstdio>
#include <iostream>
#define LL long long

int v, n;
LL f[10001];

inline int read()
{
int x = 0, f = 1;
char ch = getchar();
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
for(; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
return x * f;
}

int main()
{
int i, j, x;
v = read();
n = read();
f[0] = 1;
for(i = 1; i <= v; i++)
{
x = read();
for(j = x; j <= n; j++) f[j] += f[j - x];
}
printf("%lld\n", f
);
return 0;
}

  

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: