标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2841 Accepted Submission(s): 1276
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include <queue> using namespace std; bool p[10005]; void init(){ p[1] = true; for(int i=2;i<=10000;i++){ if(!p[i]){ for(int j=i*i;j<=10000;j+=i) p[j] = true; } } } int main(){ init(); int n; while(scanf("%d",&n)!=EOF){ int cnt = 0; for(int i=2;i<n/2;i++){ for(int j=i;j<n/2;j++){ int k = n-i-j; if(!p[i]&&!p[j]&&!p[k]&&k>=j){ cnt++; } } } printf("%d\n",cnt); } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5660945.html