From 1701104c481f11a585ba489e6477c4ac3de8efa3 Mon Sep 17 00:00:00 2001 From: KiritoTRw <3021577574@qq.com> Date: Sat, 7 May 2016 19:53:53 +0800 Subject: [PATCH] Create 1028_cnblogs.cpp http://www.cnblogs.com/qiufeihai/archive/2012/09/11/2680840.html --- HDOJ/1028_cnblogs.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 HDOJ/1028_cnblogs.cpp diff --git a/HDOJ/1028_cnblogs.cpp b/HDOJ/1028_cnblogs.cpp new file mode 100644 index 0000000..8d8701c --- /dev/null +++ b/HDOJ/1028_cnblogs.cpp @@ -0,0 +1,30 @@ +#include +#include +#include +using namespace std; + +const int M = 120 + 10; + +int dp[M]; + +int main() +{ + int n; + while (~scanf("%d", &n)) + { + + 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]; + } + } + + printf("%d\n", dp[n]); + } + return 0; +}