結果

問題 No.843 Triple Primes
ユーザー CleyLCleyL
提出日時 2022-04-23 11:17:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 73,760 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-07 03:39:31
合計ジャッジ時間 5,342 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,504 KB
testcase_01 AC 129 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 92 ms
4,384 KB
testcase_08 AC 104 ms
4,380 KB
testcase_09 AC 125 ms
4,376 KB
testcase_10 AC 97 ms
4,376 KB
testcase_11 AC 111 ms
4,380 KB
testcase_12 AC 120 ms
4,376 KB
testcase_13 AC 116 ms
4,376 KB
testcase_14 AC 113 ms
4,376 KB
testcase_15 AC 94 ms
4,376 KB
testcase_16 AC 96 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 21 ms
4,380 KB
testcase_21 AC 10 ms
4,376 KB
testcase_22 AC 57 ms
4,376 KB
testcase_23 AC 60 ms
4,380 KB
testcase_24 AC 23 ms
4,384 KB
testcase_25 AC 16 ms
4,380 KB
testcase_26 AC 125 ms
4,376 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 AC 117 ms
4,380 KB
testcase_29 AC 25 ms
4,380 KB
testcase_30 AC 122 ms
4,380 KB
testcase_31 AC 6 ms
4,380 KB
testcase_32 AC 4 ms
4,380 KB
testcase_33 AC 29 ms
4,384 KB
testcase_34 AC 50 ms
4,384 KB
testcase_35 AC 125 ms
4,380 KB
testcase_36 AC 15 ms
4,380 KB
testcase_37 AC 87 ms
4,380 KB
testcase_38 AC 70 ms
4,380 KB
testcase_39 AC 119 ms
4,380 KB
testcase_40 WA -
testcase_41 AC 1 ms
4,376 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(){
  long long n;cin>>n;
  SieveEratos A(n+1);
  int ans = 0;
  for(long long i = 0; n >= i; i++){
    if(!A[i])continue;
    for(long long j = 0; n >= j*j; j++){
      if(!A[j] || j*j-i < 0)continue;
      //cout << i << " " << j << endl;
      if(A[j*j-i])ans++;
    }
  }
  cout << ans << endl;
}
0