Title Description
Given a natural number N, N required to be split into several positive integers the sum of formats in the adding operation may be repeated a number. Program Number 2147483648 seeking result of splitting mod. 1≤N≤4000.
Entry
An integer n.
Export
The output of a number, the number of programs that is all
because this number may be quite large, so you just output this number 2147483648 to the remainder mod.
Sample input
7
Sample Output
14
prompt
Split 7 of a total of 14 cases
7=1+6
7=1+1+5
7=1+1+1+4
7=1+1+1+1+3
7=1+1+1+1+1+2
7=1+1+1+1+1+1+1
7=1+1+1+2+2
7=1+1+2+3
7=1+2+4
7=1+2+2+2
7=1+3+3
7=2+5
7=2+2+3
7=3+4
Simple dp, just pay attention to enumerate items first and then to enumerate capacity.
#include<iostream> #include<cstdio> #include<cstring> #define int long long #define mod 2147483648 using namespace std; int n,dp[100050]; signed main() { scanf("%lld",&n); dp[0]=1; for(int i=1;i<n;i++) { for(int j=i;j<=n;j++) { dp[j]=(dp[j]+dp[j-i])%mod; } } printf("%lld",dp[n]); return 0; }