結果

問題 No.6 使いものにならないハッシュ
ユーザー こるこる
提出日時 2017-01-04 22:13:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 488 ms / 5,000 ms
コード長 828 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 16,228 KB
最終ジャッジ日時 2023-10-14 23:04:43
合計ジャッジ時間 10,814 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,932 KB
testcase_01 AC 15 ms
7,844 KB
testcase_02 AC 488 ms
16,228 KB
testcase_03 AC 82 ms
9,664 KB
testcase_04 AC 152 ms
11,308 KB
testcase_05 AC 136 ms
10,456 KB
testcase_06 AC 306 ms
13,664 KB
testcase_07 AC 258 ms
13,328 KB
testcase_08 AC 304 ms
13,884 KB
testcase_09 AC 370 ms
15,688 KB
testcase_10 AC 15 ms
7,916 KB
testcase_11 AC 85 ms
9,560 KB
testcase_12 AC 307 ms
13,712 KB
testcase_13 AC 345 ms
15,184 KB
testcase_14 AC 348 ms
15,268 KB
testcase_15 AC 266 ms
13,008 KB
testcase_16 AC 347 ms
14,940 KB
testcase_17 AC 433 ms
16,060 KB
testcase_18 AC 455 ms
16,068 KB
testcase_19 AC 403 ms
15,684 KB
testcase_20 AC 335 ms
14,364 KB
testcase_21 AC 54 ms
8,812 KB
testcase_22 AC 387 ms
15,176 KB
testcase_23 AC 321 ms
13,744 KB
testcase_24 AC 355 ms
14,640 KB
testcase_25 AC 263 ms
13,368 KB
testcase_26 AC 411 ms
15,556 KB
testcase_27 AC 366 ms
15,300 KB
testcase_28 AC 206 ms
11,672 KB
testcase_29 AC 416 ms
15,612 KB
testcase_30 AC 357 ms
14,532 KB
testcase_31 AC 353 ms
14,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

k=int(input())
n=int(input())
a=list(range(n+1))
a[1]=0
count=2
while count**2<=n:
    i=2
    while count*i<=n:
        a[count*i]=0
        i+=1
    count+=1
list=[]
sum_list=[]

def fun(num):
    while int(num)>=10:
        sum=0
        for i in range(len(str(num))):
            sum+=int(str(num)[i])
        num=sum
    return num

for i in a:
    if k<=i and i<=n and i>0:
        list.append(fun(i))
        sum_list.append(i)


dp=[False]*10
max=0
sum=0
for i in range(len(list)):
    dp = [False] * 10
    count=0
    dp[list[i]]=True
    for j in range(i+1,len(list)):
        if dp[list[j]]:
            if max<=count:
                sum=sum_list[i]
                max=count
            break;
        dp[list[j]]=True
        count+=1
    if max <= count:
        sum = sum_list[i]
        max = count

print(sum)
0