Time Limits: 1000 ms Memory Limits: 65536 KB Detailed Limits
1 #include<bits/stdc++.h>
2 using namespace std;
3 long long dp[1039][1039],tot,ans;
4 int main()
5 {
6 long long n,a,b,c;
7 scanf("%lld",&n);
8 dp[0][0]=1;
9 for(a=2;a<=n;a++)
10 {
11 for(b=2;b<a;b++)
12 {
13 if(a%b==0)
14 {
15 break;
16 }
17 }
18 if(b==a)
19 {
20 for(b=0;b<=n;b++)
21 {
22 dp[tot+1][b]+=dp[tot][b];
23 for(c=a;b+c<=n;c*=a)
24 {
25 dp[tot+1][b+c]+=dp[tot][b];
26 }
27 }
28 tot++;
29 }
30 }
31 for(int a=0;a<=n;a++)
32 {
33 ans+=dp[tot][a];
34 }
35 printf("%lld",ans);
36 return 0;
37 }