#include<cstdio>
#include<iostream>
#include<string.h>
#include<vector>
using namespace std;
const int maxn = 1120 + 5;
bool prime[maxn];
vector<int> res;
void init(){
memset(prime,0,sizeof(prime));
for(int i = 2; i <= maxn; ++i) prime[i] = 1;
for(int i = 2; i <= maxn; i += 2) prime[i] = 0;
prime[2] = 1;
for(int i = 3; i<= maxn; ++i)
{
if(prime[i])
for(int j = i * 2; j <= maxn; j += i) prime[j] = 0;
}
res.clear();
for(int i = 2; i <= maxn; ++i)
if(prime[i]) res.push_back(i);
return ;
}
int d[maxn][15];
int main()
{
init();
memset(d,0,sizeof(d));
d[0][0]=1;
int lim=res.size();
for(int i=0;i<lim;i++)
{
for(int j=14;j>=1;j--)
{
for(int k=maxn-5;k>=res[i];k--)
{
d[k][j]+=d[k-res[i]][j-1];
}
}
}
int n, k;
while(scanf("%d%d", &n, &k) != EOF)
{
if(n==0 && k ==0) return 0;
cout << d[n][k] << endl;
}
return 0;
}
UVA 1213 Sum of Different Primes
最新推荐文章于 2021-02-19 10:25:14 发布