結果

問題 No.843 Triple Primes
ユーザー kekurekekure
提出日時 2019-07-06 10:21:01
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 892 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 81,756 KB
実行使用メモリ 78,544 KB
最終ジャッジ日時 2023-10-25 04:17:34
合計ジャッジ時間 6,222 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,620 KB
testcase_01 AC 145 ms
74,780 KB
testcase_02 RE -
testcase_03 AC 47 ms
62,080 KB
testcase_04 AC 51 ms
62,220 KB
testcase_05 AC 48 ms
62,080 KB
testcase_06 AC 53 ms
64,484 KB
testcase_07 AC 121 ms
72,068 KB
testcase_08 AC 131 ms
74,420 KB
testcase_09 AC 144 ms
74,776 KB
testcase_10 AC 125 ms
74,124 KB
testcase_11 AC 135 ms
74,432 KB
testcase_12 AC 140 ms
74,448 KB
testcase_13 AC 138 ms
74,440 KB
testcase_14 AC 138 ms
74,444 KB
testcase_15 AC 122 ms
72,072 KB
testcase_16 AC 126 ms
72,144 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 38 ms
53,620 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 97 ms
71,312 KB
testcase_23 AC 99 ms
71,320 KB
testcase_24 AC 72 ms
66,548 KB
testcase_25 AC 67 ms
66,548 KB
testcase_26 AC 143 ms
74,776 KB
testcase_27 AC 56 ms
64,500 KB
testcase_28 RE -
testcase_29 AC 73 ms
68,596 KB
testcase_30 AC 142 ms
74,448 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 75 ms
68,596 KB
testcase_34 AC 92 ms
69,072 KB
testcase_35 AC 145 ms
74,776 KB
testcase_36 AC 65 ms
66,548 KB
testcase_37 AC 118 ms
72,056 KB
testcase_38 AC 106 ms
71,544 KB
testcase_39 AC 141 ms
74,448 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 128 ms
74,128 KB
testcase_43 AC 137 ms
74,432 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) + 1

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