标签:cte careful scanf 构造 ESS not i++ tar it!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 24796 Accepted Submission(s):
17138
#include<cstdio> #include<cstring> #include<algorithm> const int MAXN = 121; inline int read() { char c = getchar(); int x = 0, f = 1; while(c < ‘0‘ || c > ‘9‘) {if(c == ‘-‘) f = -1; c = getchar();} while(c >= ‘0‘ && c <= ‘9‘) x = x * 10 + c - ‘0‘, c = getchar(); return x * f; } int cur[MAXN], nxt[MAXN]; main() { int N; while(scanf("%d", &N) != EOF) { memset(cur, 0, sizeof(cur)); for(int i = 0; i <= N; i++) cur[i] = 1; for(int i = 2; i <= N; i++) { for(int j = 0; j <= N; j++) for(int k = 0; j + i * k <= N; k++) nxt[j + k * i] += cur[j]; memcpy(cur, nxt, sizeof(nxt)); memset(nxt, 0, sizeof(nxt)); } printf("%d\n", cur[N]); } return 0; }
HDU 1028 Ignatius and the Princess III(生成函数)
标签:cte careful scanf 构造 ESS not i++ tar it!
原文地址:https://www.cnblogs.com/zwfymqz/p/9154805.html