#include <iostream> #include <cstring> #include <cmath> #include <algorithm> using namespace std ; const int M =1e4+33; int b[M],c[M],tot; int s[M] ; void init(int top){ memset(b,1,sizeof b); b[1]=0; int i,j; for(i=2;i<=top;i++){ if(b[i]) c[++tot]=i; for(j=1;j<=tot&&i*c[j]<=top;j++){ b[i*c[j]]=0; if(i%c[j]==0) break; } } } signed main(){ init(1e4); int i,j,x; for(i=1;i<=tot;i++) s[i]=s[i-1]+c[i]; while(cin>>x,x){ int cnt=0; for(i=1;i<=tot;i++) for(j=i;j<=tot;j++){ if(s[j]-s[i-1]==x) cnt++; } cout<<cnt<<endl; } }
标签:Prime,int,Sum,121,Numbers,include From: https://www.cnblogs.com/towboa/p/17304208.html