結果

問題 No.6 使いものにならないハッシュ
ユーザー ntudantuda
提出日時 2024-02-25 22:31:54
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 870 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 104,448 KB
最終ジャッジ日時 2024-02-25 22:31:59
合計ジャッジ時間 4,927 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,716 KB
testcase_01 AC 35 ms
53,716 KB
testcase_02 AC 147 ms
104,448 KB
testcase_03 AC 61 ms
76,100 KB
testcase_04 AC 75 ms
78,328 KB
testcase_05 AC 69 ms
76,956 KB
testcase_06 AC 106 ms
90,740 KB
testcase_07 AC 101 ms
88,744 KB
testcase_08 AC 108 ms
91,408 KB
testcase_09 AC 140 ms
103,668 KB
testcase_10 RE -
testcase_11 AC 60 ms
75,948 KB
testcase_12 AC 104 ms
89,492 KB
testcase_13 AC 129 ms
99,536 KB
testcase_14 AC 132 ms
99,856 KB
testcase_15 AC 95 ms
86,100 KB
testcase_16 AC 128 ms
98,852 KB
testcase_17 AC 144 ms
103,700 KB
testcase_18 AC 144 ms
103,684 KB
testcase_19 AC 137 ms
101,184 KB
testcase_20 AC 117 ms
93,552 KB
testcase_21 AC 53 ms
72,824 KB
testcase_22 AC 129 ms
98,892 KB
testcase_23 AC 107 ms
90,896 KB
testcase_24 AC 119 ms
95,432 KB
testcase_25 AC 103 ms
88,896 KB
testcase_26 AC 137 ms
101,180 KB
testcase_27 AC 128 ms
98,868 KB
testcase_28 AC 84 ms
81,144 KB
testcase_29 AC 136 ms
101,184 KB
testcase_30 AC 119 ms
95,192 KB
testcase_31 AC 122 ms
95,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def seachPrimeNum(N):
    if N == 2:
        return []
    max = int(N ** 0.5)
    seachList = [i for i in range(2, N + 1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

from bisect import bisect_left
K = int(input())
N = int(input())
PL = seachPrimeNum(N)
k = bisect_left(PL, K)
X = [-1] * 10

def f(x):
    while x >= 10:
        ret = 0
        while x > 0:
            ret += x % 10
            x //= 10
        x = ret
    return x

n = len(PL)
i = n - 1
tmp2 = 0
tmp = n - 1
while i >= k:
    h = f(PL[i])
    if X[h] != -1:
        if tmp >= X[h]:
            tmp = X[h] - 1
    X[h] = i
    if tmp2 < tmp - i + 1:
        tmp2 = tmp - i + 1
        ans = PL[i]
    i -= 1
print(ans)
0