結果
| 問題 |
No.843 Triple Primes
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2019-06-28 21:37:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 694 bytes |
| コンパイル時間 | 1,537 ms |
| コンパイル使用メモリ | 165,784 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 04:29:05 |
| 合計ジャッジ時間 | 2,788 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003;
int main(){
int N;cin>>N;
if(N==1) cout<<0<<endl;
else if(N==2) cout<<1<<endl;
else{
int ans=1;
for(int r=3;r*r<=N;r+=2){
int q=r*r-2;
bool flag=true;
for(int i=3;i*i<=r;i++){
if(r%i==0) flag=false;
}
for(int i=3;i*i<=q;i+=2){
if(q%i==0) flag=false;
}
if(flag){
ans+=2;
//cout<<2<<" "<<q<<" "<<r<<endl;
}
}
cout<<ans<<endl;
}
}
Rubikun