SZU 2015 Winter Training_2 Day#1(Basics)
20:00:37
576:00:00
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
bool f[10010];
int main()
{
int i,j,j1,a,k,z;
for (i=2;i<=10000;i++)
{
if (f[i]==false)
{
for (j=i*i;j<=10000;j=j+i)
{
f[j]=true;
}
}
}
while(scanf("%d",&a)!=EOF)
{
if (a==0) break;
z=0;k=0;
for (j1=2;j1<=a;j1++)
{
z=0;
if (f[j1]==false)
{
for (j=j1;j<=a;j++)
{
if (f[j]==false)
z=z+j;
if (z==a) { k++;break;}
}
}
}
printf("%d\n",k);
}
return 0;
}
1