結果

問題 No.843 Triple Primes
ユーザー kekurekekure
提出日時 2019-07-06 10:53:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,704 KB
実行使用メモリ 78,476 KB
最終ジャッジ日時 2023-10-25 06:15:49
合計ジャッジ時間 5,636 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,600 KB
testcase_01 AC 154 ms
74,776 KB
testcase_02 AC 49 ms
62,076 KB
testcase_03 AC 48 ms
62,076 KB
testcase_04 AC 52 ms
62,216 KB
testcase_05 AC 49 ms
62,076 KB
testcase_06 AC 54 ms
64,480 KB
testcase_07 AC 124 ms
72,064 KB
testcase_08 AC 133 ms
74,416 KB
testcase_09 AC 146 ms
74,772 KB
testcase_10 AC 127 ms
74,120 KB
testcase_11 AC 137 ms
74,428 KB
testcase_12 AC 142 ms
74,444 KB
testcase_13 AC 139 ms
74,436 KB
testcase_14 AC 138 ms
74,440 KB
testcase_15 AC 125 ms
72,068 KB
testcase_16 AC 127 ms
72,072 KB
testcase_17 WA -
testcase_18 AC 39 ms
53,600 KB
testcase_19 AC 38 ms
53,600 KB
testcase_20 AC 70 ms
66,544 KB
testcase_21 AC 63 ms
66,544 KB
testcase_22 AC 97 ms
71,308 KB
testcase_23 AC 100 ms
71,316 KB
testcase_24 AC 73 ms
66,544 KB
testcase_25 AC 69 ms
66,544 KB
testcase_26 AC 147 ms
74,772 KB
testcase_27 AC 57 ms
64,496 KB
testcase_28 RE -
testcase_29 AC 74 ms
68,592 KB
testcase_30 AC 142 ms
74,444 KB
testcase_31 AC 60 ms
64,496 KB
testcase_32 AC 56 ms
64,496 KB
testcase_33 AC 77 ms
68,592 KB
testcase_34 AC 92 ms
69,068 KB
testcase_35 AC 145 ms
74,772 KB
testcase_36 AC 66 ms
66,544 KB
testcase_37 AC 122 ms
72,052 KB
testcase_38 AC 107 ms
71,540 KB
testcase_39 AC 142 ms
74,444 KB
testcase_40 AC 39 ms
53,600 KB
testcase_41 WA -
testcase_42 AC 136 ms
74,124 KB
testcase_43 AC 137 ms
74,428 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] == k) :
            break
        i_q += 1
    i_r += 1

print(cnt * 2 + 1)
            



    
0