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]);
	}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章