注意会爆int。
/*
project euler problem 10: 求小于 2000000 的所有质数之和
answer:
*/
#include<bits/stdc++.h>
using namespace std;
const int N = 2000000 + 1;
int st[N];
int main(void)
{
vector<int> primes;
for (int i = 2; i < N; ++i)
{
if (st[i]) continue;
primes.push_back(i);
for (int j = 2; j * i < N; ++ j) st[j * i] = 1;
}
long long ans = 0;
for (auto x: primes) ans += (long long) x;
cout << ans << endl;
return 0;
}