結果
| 問題 |
No.843 Triple Primes
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-04-23 11:17:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 652 bytes |
| コンパイル時間 | 745 ms |
| コンパイル使用メモリ | 72,668 KB |
| 最終ジャッジ日時 | 2025-01-28 21:04:27 |
|
ジャッジサーバー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(){
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;
}