結果

問題 No.843 Triple Primes
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-05-21 15:33:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 1,043 ms
コンパイル使用メモリ 81,852 KB
実行使用メモリ 82,900 KB
最終ジャッジ日時 2023-10-20 16:18:07
合計ジャッジ時間 5,784 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,600 KB
testcase_01 AC 133 ms
82,900 KB
testcase_02 AC 47 ms
62,424 KB
testcase_03 AC 47 ms
62,424 KB
testcase_04 AC 48 ms
62,436 KB
testcase_05 AC 46 ms
62,424 KB
testcase_06 AC 48 ms
62,436 KB
testcase_07 AC 101 ms
78,860 KB
testcase_08 AC 109 ms
80,660 KB
testcase_09 AC 131 ms
82,868 KB
testcase_10 AC 103 ms
79,028 KB
testcase_11 AC 117 ms
80,880 KB
testcase_12 AC 127 ms
82,752 KB
testcase_13 AC 122 ms
81,032 KB
testcase_14 AC 121 ms
81,036 KB
testcase_15 AC 101 ms
78,932 KB
testcase_16 AC 103 ms
78,996 KB
testcase_17 AC 37 ms
53,600 KB
testcase_18 AC 37 ms
53,600 KB
testcase_19 AC 37 ms
53,600 KB
testcase_20 AC 59 ms
69,284 KB
testcase_21 AC 54 ms
65,056 KB
testcase_22 AC 77 ms
74,188 KB
testcase_23 AC 79 ms
75,288 KB
testcase_24 AC 60 ms
69,364 KB
testcase_25 AC 60 ms
68,280 KB
testcase_26 AC 131 ms
82,856 KB
testcase_27 AC 50 ms
64,704 KB
testcase_28 AC 125 ms
81,084 KB
testcase_29 AC 61 ms
69,900 KB
testcase_30 AC 128 ms
82,772 KB
testcase_31 AC 50 ms
64,832 KB
testcase_32 AC 49 ms
62,628 KB
testcase_33 AC 63 ms
70,064 KB
testcase_34 AC 75 ms
73,940 KB
testcase_35 AC 132 ms
82,868 KB
testcase_36 AC 58 ms
65,804 KB
testcase_37 AC 97 ms
78,688 KB
testcase_38 AC 84 ms
75,688 KB
testcase_39 AC 127 ms
82,380 KB
testcase_40 AC 37 ms
53,600 KB
testcase_41 AC 36 ms
53,600 KB
testcase_42 AC 107 ms
80,532 KB
testcase_43 AC 116 ms
80,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
primes = []
ans = 0
r = set()
pq = set()
count = [0]*(n+1)
for i in range(2,n+1):
    if count[i]:
        continue
    primes.append(i)
    for j in range(i,n+1,i):
        count[j] += 1

    r.add(i**2)
    pq.add(i)

    # for j in r:
    #     if j-i in pq:
    #         if i == j-i:
    #             ans += 1
    #         else:
    #             ans += 2

for i in r:
    if i > 2*n:
        continue
    for p in primes:
        if p > i:
            break
        if i-p < p:
            break
        if i-p in pq:
            if p == i-p:
                ans += 1
            else:
                ans += 2
print(ans)
0