Divide N into the sum of several different integers, how many different division methods are there, for example: n = 6, {6}{1,5}{2,4}{1,2,3}, a total of 4 kinds. Since the data is large, the result of Mod 10^9 + 7 can be output.
Input Input 1 number N (1 <= N <= 50000). Output The number of output divisions Mod 10^9 + 7. Sample Input
Input Input 1 number N (1 <= N <= 50000). Output The number of output divisions Mod 10^9 + 7. Sample Input
6Sample Output
4
#include <cstdio>
#include <string>
#include <cstring>
#include <math.h>
#include <iostream>
#include <algorithm>
using namespace std;
int dp[50005][351];
int main(){
int n;
while(scanf("%d",&n)!=EOF){
memset(dp,0,sizeof(dp));
dp[1][1]=1;
for(int i=2;i<=n;i++){
for(int j=1;j<min(350,i);j++){
dp[i][j]=(dp[i-j][j]+dp[i-j][j-1])%1000000007; //关键
}
}
int ans=0;
for(int i=1;i<=350;i++){
ans=(ans+dp[n][i])%1000000007;
}
printf("%d\n",years);
}
return 0;
}
dp[i][j] is to divide i into j numbers.
About Integer Division
https://blog.csdn.net/u013377068/article/details/79765694