您的位置:首页 > 编程语言 > Go语言

Codeforces goodbye 2014 a

2015-01-06 00:00 183 查看
摘要: Codeforces goodbye 2014 a

#include <iostream>
#include <fstream>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#ifdef DEBUG
ifstream in;
ofstream out;
#endif

#ifdef DEBUG
#define CIN  in
#define COUT  out
#else
#define CIN  cin
#define COUT cout
#endif

#define MAXN 1000

int table[MAXN + 10];
int n, ans, tmp;

void build_table(void)
{
memset(table, 0, sizeof(table));
for(int i = 2; i <= 1000; i++){
for(int j = i; j <= 1000; j+= i)
if(j > i)
table[j] = 1;
}
}

int  main(void)
{
#ifdef DEBUG
string buffer;
CIN.open("in", ios::in);
COUT.open("out", ios::out);
while(getline(CIN, buffer))
COUT << buffer << "\n";
COUT << "Out Put" << "\n";
CIN.close();
CIN.open("in", ios::in);
#endif
build_table();
while(CIN >> n){
ans = 0;
for(int i = 0; i < n; i++){
CIN >> tmp;
if(!table[tmp])
ans += tmp;
}
COUT << ans << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: