結果
問題 | No.843 Triple Primes |
ユーザー |
![]() |
提出日時 | 2019-06-28 22:14:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 335 bytes |
コンパイル時間 | 590 ms |
コンパイル使用メモリ | 59,484 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 14:02:35 |
合計ジャッジ時間 | 1,591 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 41 WA * 1 |
ソースコード
#include <iostream>#include <math.h>using namespace std;int isP(int a){for(int j = 3;j <= sqrt(a);j+=2)if(!(a%j)) return a%j;return (a%a)+1;}int main() {int ans = 1;int n;cin >> n;if(n < 2){cout << "0";return 0;}for(int i = 3;i*i <= n+1;i+=2)if(isP(i) && isP(i*i-2)) ans+=2;cout << ans;return 0;}