HDU-1028Ignatius and the Princess III

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028

0MS

#include<cstdio>
#include<iostream>
#include<cstring>
#define N 125
using namespace std;
int dp[N];
void init() {
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	for(int i=1; i<N; i++)
		for(int j=i; j<N; j++)
			dp[j]+=dp[j-i];
}
int main() {
	int n;
	init();
	while(~scanf("%d",&n)) {
		printf("%d\n",dp[n]);
	}
}

猜你喜欢

转载自blog.csdn.net/qq_39564498/article/details/81704383