結果

問題 No.843 Triple Primes
ユーザー kekurekekure
提出日時 2019-07-06 10:59:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 896 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 74,840 KB
最終ジャッジ日時 2023-10-25 06:36:29
合計ジャッジ時間 5,879 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,676 KB
testcase_01 AC 142 ms
74,840 KB
testcase_02 AC 47 ms
62,140 KB
testcase_03 AC 47 ms
62,140 KB
testcase_04 AC 49 ms
62,280 KB
testcase_05 AC 46 ms
62,140 KB
testcase_06 AC 50 ms
64,544 KB
testcase_07 AC 122 ms
72,128 KB
testcase_08 AC 129 ms
74,480 KB
testcase_09 AC 141 ms
74,836 KB
testcase_10 AC 124 ms
74,184 KB
testcase_11 AC 132 ms
74,492 KB
testcase_12 AC 138 ms
74,508 KB
testcase_13 AC 135 ms
74,500 KB
testcase_14 AC 137 ms
74,504 KB
testcase_15 AC 121 ms
72,132 KB
testcase_16 AC 122 ms
72,136 KB
testcase_17 WA -
testcase_18 AC 38 ms
53,676 KB
testcase_19 AC 37 ms
53,676 KB
testcase_20 AC 70 ms
66,608 KB
testcase_21 AC 60 ms
66,608 KB
testcase_22 AC 95 ms
71,372 KB
testcase_23 AC 98 ms
71,380 KB
testcase_24 AC 68 ms
66,608 KB
testcase_25 AC 65 ms
66,608 KB
testcase_26 AC 143 ms
74,836 KB
testcase_27 AC 57 ms
64,560 KB
testcase_28 AC 138 ms
74,504 KB
testcase_29 AC 71 ms
68,656 KB
testcase_30 AC 140 ms
74,508 KB
testcase_31 AC 57 ms
64,560 KB
testcase_32 AC 53 ms
64,560 KB
testcase_33 AC 75 ms
68,656 KB
testcase_34 AC 91 ms
69,132 KB
testcase_35 AC 144 ms
74,836 KB
testcase_36 AC 65 ms
66,608 KB
testcase_37 AC 118 ms
72,116 KB
testcase_38 AC 105 ms
71,604 KB
testcase_39 AC 140 ms
74,508 KB
testcase_40 AC 39 ms
53,676 KB
testcase_41 WA -
testcase_42 AC 126 ms
74,188 KB
testcase_43 AC 134 ms
74,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def makeprime(k) :
    prime = [2,3,5,7,11]

    for i in range(13, k + 1, 2) :
        if (i % 3 == 0 or i % 5 == 0 or i % 7 == 0 or i % 11 == 0) :
            continue
        limit = int(math.sqrt(i)) + 1
        isprime = False
        for x in prime :
            if (x > limit) :
                isprime = True
                break
            if (i % x == 0) :
                break
        if (isprime) :
            prime.append(i)
    
    return prime

k = int(input())
prime = makeprime(k)

i_r = 1
i_q = 3
cnt = 0

last_prime = prime[-1]
limit_r = math.sqrt(2 + k)

while (prime[i_r] <= limit_r) :
    R = prime[i_r] ** 2
    while (True) :
        Q = 2 + prime[i_q]
        if (R == Q) :
            cnt += 1
            break
        elif (Q > R or prime[i_q] == last_prime) :
            break
        i_q += 1
    i_r += 1

print(cnt * 2 + 1)
            



    
0