您的位置:首页 > 其它

hdu1028 Ignatius and the Princess III(生成函数整理占坑)upd 已咕

2018-05-20 18:06 399 查看
先咕着

---------------2018 5 22----------------------

题解

生成函数处理整数拆分

code

#include<cstdio>
#include<cstring>
#include<algorithm>
inline int raed() {
int x = 0,f = 1;
char c = getchar();
while(c < '0' || c < '9') c = getchar();
while(c <= '9' && c >= '0')x = x * 10 + c - '0',c = getchar();
return x * f;
}
const int maxn = 564;
int a[maxn],b[maxn];
int main() {
int n;
while(scanf("%d",&n) == 1) {
for(int i = 0;i <= n;++ i)
a[i] = 1,b[i] = 0;
for(int i = 2;i <= n;++ i) {
for(int j = 0;j <= n;++ j)
for(int k = 0;k + j <= n;k += i)
b[j + k] += a[j];
for(int j = 0;j <= n;++ j)
a[j] = b[j],b[j] = 0;
}
printf("%d\n",a
);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: