結果
問題 | No.843 Triple Primes |
ユーザー | ikd |
提出日時 | 2019-06-28 22:59:42 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 710 bytes |
コンパイル時間 | 630 ms |
コンパイル使用メモリ | 73,880 KB |
実行使用メモリ | 6,408 KB |
最終ジャッジ日時 | 2023-09-14 22:32:35 |
合計ジャッジ時間 | 11,613 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | WA | - |
testcase_04 | AC | 3 ms
4,376 KB |
testcase_05 | AC | 3 ms
4,376 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | RE | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 1 ms
4,376 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | WA | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | AC | 2 ms
4,380 KB |
testcase_41 | AC | 2 ms
4,376 KB |
testcase_42 | WA | - |
testcase_43 | WA | - |
ソースコード
#include <algorithm> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; bool is_prime(int64_t x) { for (int64_t y = 2; y * y <= x; y++) { if (x % y == 0) return false; } return true; } int main() { int n; cin >> n; vector<int64_t> primes; for (int64_t x = 2; x <= n; x++) { if (is_prime(x)) primes.push_back(x); } vector<int> exists(n + 1, false); for (auto p : primes) { exists[p] = true; } int ans = 0; for (auto r : primes) { if (r * r > n * 2) break; for (auto p : primes) { auto q = r * r - p; if (q >= 0 and exists[q]) { ans += 1; } } } cout << ans << endl; return 0; }