結果

問題 No.6 使いものにならないハッシュ
ユーザー miztommiztom
提出日時 2024-03-12 14:55:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 5,000 ms
コード長 389 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 80,152 KB
最終ジャッジ日時 2024-03-12 14:55:37
合計ジャッジ時間 5,153 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 112 ms
80,152 KB
testcase_03 AC 79 ms
76,684 KB
testcase_04 AC 84 ms
77,408 KB
testcase_05 AC 80 ms
77,032 KB
testcase_06 AC 100 ms
78,528 KB
testcase_07 AC 99 ms
78,016 KB
testcase_08 AC 96 ms
78,456 KB
testcase_09 AC 106 ms
79,040 KB
testcase_10 AC 34 ms
53,460 KB
testcase_11 AC 74 ms
76,664 KB
testcase_12 AC 101 ms
78,472 KB
testcase_13 AC 100 ms
78,656 KB
testcase_14 AC 114 ms
78,968 KB
testcase_15 AC 92 ms
78,088 KB
testcase_16 AC 104 ms
78,840 KB
testcase_17 AC 109 ms
79,060 KB
testcase_18 AC 115 ms
79,816 KB
testcase_19 AC 112 ms
79,288 KB
testcase_20 AC 103 ms
78,500 KB
testcase_21 AC 68 ms
76,316 KB
testcase_22 AC 104 ms
78,736 KB
testcase_23 AC 98 ms
78,544 KB
testcase_24 AC 110 ms
78,880 KB
testcase_25 AC 95 ms
78,160 KB
testcase_26 AC 109 ms
79,288 KB
testcase_27 AC 103 ms
78,724 KB
testcase_28 AC 86 ms
77,448 KB
testcase_29 AC 110 ms
79,288 KB
testcase_30 AC 106 ms
78,848 KB
testcase_31 AC 102 ms
78,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

k=int(input())
n=int(input())
p=[1]*-~n
p[0]=p[1]=0
h=[None]*-~n
h[:10]=*range(10),
for i in range(n+1):
    if p[i]:
        for j in range(i*i,n+1,i):p[j]=0
    h[i]=h[sum(map(int,str(i)))]
h=[(h[i],i)for i in range(k,n+1)if p[i]]+[[0,0]]
s={0}
m=len(h)-1
p=0
r=(0,0)
for i in range(m):
    while h[p][0] not in s:s|={h[p][0]};p+=1
    r=max(r,(p-i,h[i][1]))
    s^={h[i][0]}
print(r[1])
0