結果

問題 No.713 素数の和
ユーザー CleyLCleyL
提出日時 2020-01-22 10:28:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 70,320 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 00:47:01
合計ジャッジ時間 1,264 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0