結果
問題 |
No.713 素数の和
|
ユーザー |
👑 |
提出日時 | 2020-01-22 10:28:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 497 bytes |
コンパイル時間 | 644 ms |
コンパイル使用メモリ | 69,668 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 17:41:48 |
合計ジャッジ時間 | 1,121 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
#include <iostream> #include <vector> using namespace std; struct SieveEratos{ vector<bool> t; SieveEratos(int n):t(n+1,true){ t[0] = t[1] = false; for(int i = 2; n >= i; i++){ if(t[i]){ for(int j = i+i; n >= j; j+=i){ t[j] = false; } } } } bool operator[](int x){return t[x];} }; int main(){ int n;cin>>n; SieveEratos a(1001); int sm = 0; for(int i = 0; n >= i; i++){ if(a[i])sm+=i; } cout << sm << endl; }