http://acm.hdu.edu.cn/showproblem.php?pid=5104
#include#include #include #include #include using namespace std;int isp[10000+100];int prime[10000];int coun;bool isprime(int x){ int i,j; for(i=2;i<=sqrt(x);i++) { if(x%i==0) return false; } return true;}void fun(){ int i,j; for(i=2;i<=10000;i++) { if(isp[i]!=0) continue; if(isprime(i)) { isp[i]=1; prime[coun++]=i; } j=i; while(j+i<=10000) { j+=i; isp[j]=2; } }}int main(){ //freopen("output.txt","w",stdout); int ans; int i,j,k,n; memset(isp,0,sizeof(isp)); coun=0; fun(); //printf("%d...\n",coun); while(scanf("%d",&n)!=EOF) { int ans=0; for(i=0;i n/3) break; for(j=i;prime[j]<=(n-prime[i])/2;j++) { k=n-prime[i]-prime[j]; if(isp[k]==1) ans++; } } printf("%d\n",ans); //n++; } return 0;}