結果

問題 No.6 使いものにならないハッシュ
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-04-12 21:04:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 198 ms / 5,000 ms
コード長 776 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 78,756 KB
最終ジャッジ日時 2023-09-11 02:17:37
合計ジャッジ時間 7,313 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,084 KB
testcase_01 AC 75 ms
71,460 KB
testcase_02 AC 198 ms
78,756 KB
testcase_03 AC 129 ms
78,036 KB
testcase_04 AC 134 ms
78,196 KB
testcase_05 AC 134 ms
78,112 KB
testcase_06 AC 150 ms
77,984 KB
testcase_07 AC 143 ms
78,144 KB
testcase_08 AC 148 ms
77,968 KB
testcase_09 AC 152 ms
78,024 KB
testcase_10 AC 74 ms
71,324 KB
testcase_11 AC 126 ms
77,840 KB
testcase_12 AC 150 ms
78,036 KB
testcase_13 AC 141 ms
78,012 KB
testcase_14 AC 149 ms
78,160 KB
testcase_15 AC 142 ms
77,728 KB
testcase_16 AC 158 ms
78,128 KB
testcase_17 AC 160 ms
78,184 KB
testcase_18 AC 166 ms
78,364 KB
testcase_19 AC 162 ms
77,972 KB
testcase_20 AC 153 ms
78,364 KB
testcase_21 AC 117 ms
77,724 KB
testcase_22 AC 155 ms
77,812 KB
testcase_23 AC 148 ms
78,320 KB
testcase_24 AC 151 ms
77,760 KB
testcase_25 AC 143 ms
77,888 KB
testcase_26 AC 159 ms
78,008 KB
testcase_27 AC 153 ms
78,436 KB
testcase_28 AC 133 ms
78,180 KB
testcase_29 AC 158 ms
78,456 KB
testcase_30 AC 154 ms
78,040 KB
testcase_31 AC 150 ms
78,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

k = int(input())
n = int(input())

primes = []
l = []
for i in range(2,n+1):
    check = True
    for p in primes:
        if p**2 > i:
            break
        if i%p == 0:
            check = False
            break
    if check:
        primes.append(i)
        if k <= i <= n:
            l.append(i)

def hash(x):
    now = x
    while True:
        now = sum([int(i) for i in str(now)])
        if now < 10:
            return now

count = [0]*10
now = 0
ans = []
hashl = [hash(i) for i in l]

for i,h in enumerate(hashl):
    while now < len(l) and count[hashl[now]] == 0:
        count[hashl[now]] += 1
        now += 1
    ans.append(now-i)
    count[hashl[i]] -= 1
m = max(ans)
for i in range(len(ans))[::-1]:
    if ans[i] == m:
        print(l[i])
        exit()
0