HDU 1028

母函数

#include 
#include 
#include 

using namespace std;

int c1[400], c2[400];

int main() {
	int n;
	while(scanf("%d", &n) != EOF) {
		int i, j, k;
		for(i = 0; i < 400; i++) {
			c1[i] = 1;
			c2[i] = 0;
		}
		for(i = 2; i <= n; i++) {
			for(j = 0; j <= n; j++) {
				for(k = 0; k+j <= n; k+=i) {
					c2[j+k] += c1[j];
				}
			}
			for(j = 0; j <= n; j++) {
				c1[j] = c2[j];
				c2[j] = 0;
			}
		}
		printf("%d\n", c1[n]);
	}
	return 0;
}


你可能感兴趣的:(ACM,Mathematics)