結果

問題 No.6 使いものにならないハッシュ
ユーザー roiti46roiti46
提出日時 2015-02-16 23:23:58
言語 Python2
(2.7.18)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 649 bytes
コンパイル時間 42 ms
コンパイル使用メモリ 6,740 KB
実行使用メモリ 9,300 KB
最終ジャッジ日時 2023-10-14 22:49:22
合計ジャッジ時間 4,062 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
9,296 KB
testcase_01 AC 35 ms
9,296 KB
testcase_02 AC 146 ms
9,212 KB
testcase_03 AC 51 ms
9,212 KB
testcase_04 AC 57 ms
9,216 KB
testcase_05 AC 69 ms
9,204 KB
testcase_06 AC 91 ms
9,116 KB
testcase_07 AC 65 ms
9,132 KB
testcase_08 AC 81 ms
9,216 KB
testcase_09 AC 49 ms
9,116 KB
testcase_10 RE -
testcase_11 AC 56 ms
9,276 KB
testcase_12 AC 111 ms
9,220 KB
testcase_13 AC 43 ms
9,256 KB
testcase_14 AC 49 ms
9,176 KB
testcase_15 AC 93 ms
9,220 KB
testcase_16 AC 66 ms
9,132 KB
testcase_17 AC 108 ms
9,216 KB
testcase_18 AC 142 ms
9,216 KB
testcase_19 AC 107 ms
9,120 KB
testcase_20 AC 101 ms
9,280 KB
testcase_21 AC 46 ms
9,096 KB
testcase_22 AC 104 ms
9,196 KB
testcase_23 AC 106 ms
9,300 KB
testcase_24 AC 103 ms
9,212 KB
testcase_25 AC 69 ms
9,204 KB
testcase_26 AC 119 ms
9,164 KB
testcase_27 AC 92 ms
9,260 KB
testcase_28 AC 76 ms
9,220 KB
testcase_29 AC 124 ms
9,220 KB
testcase_30 AC 117 ms
9,100 KB
testcase_31 AC 103 ms
9,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *
R = 200001
p = [1]*R
p[0] = p[1] = 0
for i in xrange(2,int(R**0.5)):
    if p[i]: p[2*i::i] = [0]*(len(p[2*i::i]))
p = [i for i in xrange(2,R) if p[i]]
    
K = int(raw_input())
N = int(raw_input())
ans = mx = 0
H = []
for i in xrange(bisect(p,K),bisect(p,N)):
    s = str(p[i])
    while len(s) > 1:
        s = str(sum(map(int,list(s))))
    if s in H:
        if   len(H)  > mx: mx,ans = len(H),p[i-len(H)]
        elif len(H) == mx: ans = max(ans, p[i-len(H)])
    while s in H:
        H.pop(0)
    H.append(s)
else:
    if   len(H)  > mx: ans = p[i+1-len(H)]
    elif len(H) == mx: ans = max(ans, p[i+1-len(H)])
print ans
0