01 The backpack obviously timed out. Then there is a god DP. DP[I][J] represents the number of schemes in which J number consists of I. O (NSQRT (n))
#include <cstdio> #include <cstring> #include <cctype> #include <algorithm>using namespace std; #define REP (I,s,t) for (int. i=s;i<=t;i++) #define DWN (i,s,t) for (int i=s;i>=t;i--) const int NMAX=5E4+5;CONST int MOD =1e9+7;int Dp[nmax][355];int Main () {int n;scanf ("%d", &n);DP [1][1]=1;rep (I,2,n) Rep (J,1,min (i,350)) dp[i][j]= (DP [I-j] [j]+dp[i-j][j-1])%mod;int ans=0;rep (i,1,350) ans= (Ans+dp[n][i])%mod;printf ("%d\n", ans); return 0;}
1201 integer Dividing base time limit: 1 seconds space limit: 131072 KB score: 80 Difficulty: 5-level algorithm collection attention to divide n into a number of different integers and, how many different ways, such as: n = 6,{6} {1,5} {2,4} {three-way}, a total of 4. Due to the large data, output mod 10^9 + 7 results. Input
Enter 1 number n (1 <= n <= 50000).
Output
Output divided by the number mod 10^9 + 7.
Input example
6
Output example
4
51nod1201 Integer Division