結果
| 問題 |
No.713 素数の和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-13 22:22:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 979 bytes |
| コンパイル時間 | 1,052 ms |
| コンパイル使用メモリ | 107,680 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-09 05:11:50 |
| 合計ジャッジ時間 | 1,535 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 |
ソースコード
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
void findPrime(int N, vector<bool>& isPrime)
{
isPrime.assign(N+1, true);
isPrime[0] = isPrime[1] = false;
for(int i=2; i*i<=N; i++){
if(isPrime[i]){
for(int j=i; i*j<=N; j++){
isPrime[i*j] = false;
}
}
}
}
int main()
{
int n;
cin >> n;
vector<bool> isPrime;
findPrime(n, isPrime);
int ans = 0;
for(int i=1; i<=n; ++i){
if(isPrime[i])
ans += i;
}
cout << ans << endl;
return 0;
}