标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1033 Accepted Submission(s): 612
#include<stdio.h> #include<iostream> #include<string.h> #include <stdlib.h> #include<math.h> #include<algorithm> using namespace std; typedef long long LL; const int N = 1005; int p[N]; void init(){ for(int i=2;i<=1000;i++){ if(!p[i]){ for(int j=i*i;j<=1000;j+=i){ p[j] = true; } } } } int main() { init(); int n; while(scanf("%d",&n)!=EOF){ int sum = 0; for(int i=1;i<=n;i++){ int v; scanf("%d",&v); if(!p[v]) sum+=v; } printf("%d\n",sum); } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5672415.html