結果

問題 No.843 Triple Primes
ユーザー CleyLCleyL
提出日時 2022-04-23 11:09:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 622 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 74,500 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 03:30:46
合計ジャッジ時間 3,346 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 29 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 22 ms
4,376 KB
testcase_08 AC 25 ms
4,380 KB
testcase_09 AC 29 ms
4,376 KB
testcase_10 AC 23 ms
4,380 KB
testcase_11 AC 27 ms
4,376 KB
testcase_12 AC 28 ms
4,380 KB
testcase_13 AC 27 ms
4,380 KB
testcase_14 AC 28 ms
4,380 KB
testcase_15 AC 22 ms
4,376 KB
testcase_16 AC 23 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 WA -
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 6 ms
4,376 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 14 ms
4,380 KB
testcase_23 AC 14 ms
4,376 KB
testcase_24 AC 6 ms
4,380 KB
testcase_25 AC 6 ms
4,380 KB
testcase_26 AC 29 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 28 ms
4,376 KB
testcase_29 AC 7 ms
4,376 KB
testcase_30 AC 28 ms
4,384 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 8 ms
4,380 KB
testcase_34 AC 13 ms
4,376 KB
testcase_35 AC 29 ms
4,380 KB
testcase_36 AC 5 ms
4,380 KB
testcase_37 AC 22 ms
4,376 KB
testcase_38 AC 17 ms
4,376 KB
testcase_39 AC 28 ms
4,380 KB
testcase_40 WA -
testcase_41 AC 1 ms
4,380 KB
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

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(n);
  int ans = 0;
  for(int i = 0; n >= i*i; i++){
    if(!A[i])continue;
    for(int j = 0; (i*i)/2 >= j; j++){
      if(A[j] && A[(i*i)-j]){
          ans++;
          if(j+j != i*i)ans++;
      }
    }
  }
  cout << ans << endl;
}
0