結果
問題 |
No.843 Triple Primes
|
ユーザー |
👑 |
提出日時 | 2022-04-23 11:09:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 622 bytes |
コンパイル時間 | 656 ms |
コンパイル使用メモリ | 73,292 KB |
最終ジャッジ日時 | 2025-01-28 21:04:22 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 WA * 4 |
ソースコード
#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; }