結果

問題 No.843 Triple Primes
ユーザー 👑 rin204rin204
提出日時 2020-10-02 02:58:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 1,078 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 82,720 KB
最終ジャッジ日時 2023-09-21 21:49:31
合計ジャッジ時間 7,076 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,732 KB
testcase_01 AC 106 ms
82,684 KB
testcase_02 AC 85 ms
76,576 KB
testcase_03 AC 82 ms
76,060 KB
testcase_04 AC 86 ms
76,748 KB
testcase_05 AC 81 ms
76,364 KB
testcase_06 AC 88 ms
76,736 KB
testcase_07 AC 100 ms
81,104 KB
testcase_08 AC 109 ms
81,928 KB
testcase_09 AC 105 ms
82,720 KB
testcase_10 AC 109 ms
81,460 KB
testcase_11 AC 103 ms
81,664 KB
testcase_12 AC 109 ms
82,596 KB
testcase_13 AC 104 ms
82,112 KB
testcase_14 AC 107 ms
81,940 KB
testcase_15 AC 102 ms
81,140 KB
testcase_16 AC 113 ms
81,248 KB
testcase_17 AC 75 ms
71,124 KB
testcase_18 AC 78 ms
71,728 KB
testcase_19 AC 77 ms
71,764 KB
testcase_20 AC 95 ms
77,768 KB
testcase_21 AC 87 ms
77,204 KB
testcase_22 AC 100 ms
79,332 KB
testcase_23 AC 97 ms
79,552 KB
testcase_24 AC 90 ms
77,900 KB
testcase_25 AC 91 ms
77,552 KB
testcase_26 AC 108 ms
82,660 KB
testcase_27 AC 87 ms
76,504 KB
testcase_28 AC 105 ms
81,888 KB
testcase_29 AC 90 ms
77,704 KB
testcase_30 AC 106 ms
82,380 KB
testcase_31 AC 86 ms
77,000 KB
testcase_32 AC 89 ms
76,936 KB
testcase_33 AC 90 ms
77,860 KB
testcase_34 AC 97 ms
79,284 KB
testcase_35 AC 105 ms
82,380 KB
testcase_36 AC 92 ms
77,368 KB
testcase_37 AC 100 ms
81,112 KB
testcase_38 AC 106 ms
80,060 KB
testcase_39 AC 105 ms
82,368 KB
testcase_40 AC 86 ms
71,568 KB
testcase_41 AC 73 ms
71,320 KB
testcase_42 AC 106 ms
81,536 KB
testcase_43 AC 103 ms
82,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
prime = [True for _ in range(n + 1)]
prime[0] = prime[1] = False
for i in range(2, int(n ** 0.5) + 1):
    if not prime[i]:
        continue
    for j in range(i * i, n + 1, i):
        prime[j] = False
prime_lst = []
for i in range(n + 1):
    if prime[i]:
        prime_lst.append(i)

ans = 0
p = 2
for q in prime_lst:
    rr = p + q
    r = int(rr ** 0.5)
    if r ** 2 != rr:
        continue
    elif prime[r]:
        ans += 2
        if p == q == 2:
            ans -= 1
            
print(ans)
0