模拟题吧。

#include "stdio.h"
int prime[10005];
int number[10005];
int c_table(int p)
{
    
int i,temp;
    
int addr=0;
    
for(i=2;i<=p;i++){number[i]=1;}
    
for(i=2;i<=p/2;i++)
    
{
        
if(number[i]!=0)
        
{
            
for(temp=i+i;temp<=p;temp=temp+i){number[temp]=0;}
        }

    }

    
for(i=2;i<=p;i++){if(number[i]!=0)prime[addr++]=i;}
    
return addr;
}

int main()
{
    
int n,e,count,sum;
    
int left,right;
    e
=c_table(10000);
    
while(1)
    
{
        scanf(
"%d",&n);
        
if(n==0)break;
        left
=right=0;
        count
=0;sum=prime[0];
        
do 
        
{
            
if(sum<n)
            
{
                right
++;
                sum
+=prime[right];
            }

            
else
            
{
                
if(sum>n)
                
{
                    sum
-=prime[left];
                    left
++;
                }

                
else
                
{
                    count
++;
                    right
++;
                    sum
+=prime[right];
                }

            }

        }
 while(right<e);
        printf(
"%d\n",count);
    }

    
return 0;
}