結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,716 KB
testcase_01 AC 37 ms
53,716 KB
testcase_02 AC 155 ms
104,448 KB
testcase_03 AC 64 ms
76,100 KB
testcase_04 AC 83 ms
78,324 KB
testcase_05 AC 72 ms
76,908 KB
testcase_06 AC 112 ms
90,868 KB
testcase_07 AC 105 ms
88,744 KB
testcase_08 AC 113 ms
91,408 KB
testcase_09 AC 148 ms
103,668 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 64 ms
75,948 KB
testcase_12 AC 109 ms
89,492 KB
testcase_13 AC 134 ms
99,536 KB
testcase_14 AC 138 ms
99,856 KB
testcase_15 AC 101 ms
86,100 KB
testcase_16 AC 135 ms
98,852 KB
testcase_17 AC 149 ms
103,700 KB
testcase_18 AC 152 ms
103,684 KB
testcase_19 AC 144 ms
101,184 KB
testcase_20 AC 120 ms
93,552 KB
testcase_21 AC 55 ms
72,824 KB
testcase_22 AC 135 ms
98,892 KB
testcase_23 AC 113 ms
90,896 KB
testcase_24 AC 125 ms
95,432 KB
testcase_25 AC 108 ms
88,896 KB
testcase_26 AC 143 ms
101,180 KB
testcase_27 AC 135 ms
98,868 KB
testcase_28 AC 88 ms
81,144 KB
testcase_29 AC 144 ms
101,184 KB
testcase_30 AC 125 ms
95,192 KB
testcase_31 AC 126 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
ans = 2
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