The
is a wonderful question. Take into account more than n−−√\sqrt n items, can not get the quantity limit must be beyond the size of the backpack, it could be seen as an infinite knapsack problem. And the total number of items taken must be less than n−−√\sqrt N. So we can get nn−−√n\sqrt n dp.
and N−−√\sqrt n items, directly as a general multiple knapsack problem, with the mode of classification optimization, you can remove the complexity of the number of Nn−−√n \sqrt N.
Two and a half to be counted.
So Total complexity O (nn−−√) o (n \sqrt N)
#include <cstdio> #include <cmath> #include <algorithm> #include <
Cstring> using namespace std;
typedef long Long LL;
const int maxn=100005,mod=23333333;
int N,M,F1[MAXN],SUM[MAXN],ANS,F[330][MAXN],F2[MAXN];
int main () {freopen ("51nod1597.in", "R", stdin);
Freopen ("51nod1597.out", "w", stdout); scanf ("%d", &n);
M=SQRT (n);
F1[0]=1;
for (int i=1;i<=m;i++) for (int j=0;j<=i-1;j++) {sum[0]=f1[j]; for (int k=1;j+k*i<=n;k++) sum[k]= (Sum[k-1]+f1[j+k*i])%mod, (f1[j+k*i]+=sum[k-1]-(k-i-1>=0?sum[k-i-1]:0))%=
MOD;
} f[0][0]=1;
for (int i=1;i<=m;i++) for (int j=i* (m+1); j<=n;j++) (f[i][j]+=f[i][j-i]+f[i-1][j-(m+1)])%=mod;
F2[0]=1;
for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) (f2[i]+=f[j][i])%=mod;
for (int i=0;i<=n;i++) (ans+= (LL) f1[i]*f2[n-i]%mod)%=mod;
printf ("%d\n", (ans+mod)%mod);
return 0; }