n的m整数划分(不包含重复划分):
#include <iostream> #include<cstdio> #define mod 1000000007 typedef long long ll; using namespace std; ll n,m; ll dp[1005][1005]; int main() { while(scanf("%lld%lld",&n,&m)!=EOF){ dp[0][0]=1; for(ll i=0;i<=n;i++){ for(ll j=1;j<=m;j++){ if(i>=j) dp[i][j]=(dp[i-j][j]+dp[i][j-1])%mod; else dp[i][j]=dp[i][j-1]; } } printf("%lld ",dp[n][m]); } return 0; }
划分数系列问题:https://blog.csdn.net/codingdd/article/details/61414550