結果
問題 |
No.843 Triple Primes
|
ユーザー |
![]() |
提出日時 | 2019-06-29 22:31:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 431 bytes |
コンパイル時間 | 1,506 ms |
コンパイル使用メモリ | 166,520 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-02 05:41:43 |
合計ジャッジ時間 | 2,674 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 WA * 4 |
ソースコード
#include "bits/stdc++.h" using namespace std; bool isPrime(int x) { for (int i = 2; i*i <= x; i++) { if (x % i == 0) return false; } return true; } void solve(void) { int n; cin >> n; int ans = 0; for (int i = 2; i * i <= n; i++) { if (isPrime(i) && isPrime(i*i-2)) { if (i == 2) ans++; else ans += 2; } } cout << ans << endl; } int main() { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }