https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=3654

it brings a wrong answer

```
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
bool notprime[1121];
int dp[1125]/*rem*/[1120]/*ind*/;
vector<int>primes;
int n;
void SieveOfEratosthenes(int n=1120)
{
for (int p = 2; p*p <= n; p++)
if (notprime[p] == false)
{
primes.push_back(p);
for (int i = p * 2; i <= n; i += p)
notprime[i] = true;
}
}
int solve(int rem, int ind, int no)
{
if (rem == 0)return 1;
if (no == n||ind==primes.size()||rem<0)return 0;
if (dp[rem][ind] != -1)return dp[rem][ind];
return dp[rem][ind]=solve(rem-primes[ind],ind,no+1) + solve(rem,ind+1,no);
}
int main()
{
int x;
SieveOfEratosthenes();
memset(dp, -1, sizeof dp);
cin >> x >> n;
while (x != 0 || n != 0)
{
cout<<solve(x, 0, 0)<<endl;
cin >> x >> n;
}
return 0;
}
```