結果
問題 |
No.713 素数の和
|
ユーザー |
![]() |
提出日時 | 2019-03-09 10:04:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 486 bytes |
コンパイル時間 | 1,787 ms |
コンパイル使用メモリ | 170,148 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 15:11:22 |
合計ジャッジ時間 | 2,064 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<bool> F(n + 1, true); F[0] = F[1] = false; for(int i = 2; i <= (int)(sqrt(n)); i++){ if(F[i]) for(int j = i + i; j <= n; j += i){ F[j] = false; } } int ans = 0; for(int i = 2; i <= n; i++){ if(F[i]) ans += i; } cout << ans << endl; return 0; }