結果

問題 No.6 使いものにならないハッシュ
ユーザー titiatitia
提出日時 2021-11-01 15:01:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 258 ms / 5,000 ms
コード長 863 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 19,072 KB
最終ジャッジ日時 2024-04-18 11:01:10
合計ジャッジ時間 5,797 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 27 ms
10,880 KB
testcase_02 AC 258 ms
19,072 KB
testcase_03 AC 66 ms
12,416 KB
testcase_04 AC 85 ms
13,824 KB
testcase_05 AC 95 ms
13,312 KB
testcase_06 AC 157 ms
16,384 KB
testcase_07 AC 115 ms
15,872 KB
testcase_08 AC 137 ms
16,256 KB
testcase_09 AC 114 ms
18,432 KB
testcase_10 AC 28 ms
10,880 KB
testcase_11 AC 69 ms
12,288 KB
testcase_12 AC 196 ms
16,128 KB
testcase_13 AC 107 ms
18,048 KB
testcase_14 AC 123 ms
18,048 KB
testcase_15 AC 149 ms
15,616 KB
testcase_16 AC 131 ms
17,536 KB
testcase_17 AC 207 ms
18,560 KB
testcase_18 AC 254 ms
18,688 KB
testcase_19 AC 203 ms
18,304 KB
testcase_20 AC 172 ms
17,024 KB
testcase_21 AC 49 ms
11,648 KB
testcase_22 AC 187 ms
17,792 KB
testcase_23 AC 177 ms
16,384 KB
testcase_24 AC 174 ms
17,280 KB
testcase_25 AC 126 ms
15,872 KB
testcase_26 AC 209 ms
18,176 KB
testcase_27 AC 171 ms
17,920 KB
testcase_28 AC 113 ms
14,720 KB
testcase_29 AC 221 ms
18,048 KB
testcase_30 AC 199 ms
17,280 KB
testcase_31 AC 186 ms
17,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K=int(input())
N=int(input())


def c(x):
    S=str(x)
    ANS=0
    for s in S:
        ANS+=int(s)

    if ANS<=9:
        return ANS
    else:
        return c(ANS)

x=N+1

import math 
L=math.floor(math.sqrt(x)) # 平方根を求める

Primelist=[i for i in range(x+1)]
Primelist[1]=0 # 1は素数でないので0にする.
 
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0

Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0 and K<=j<=N]

ANS=0
j=0
SET=set()
AX=0
for i in range(len(Primes)):
    while j<len(Primes) and not(c(Primes[j]) in SET):
        SET.add(c(Primes[j]))
        if ANS<=len(SET):
            AX=Primes[i]
            ANS=len(SET)
            
        j+=1
    #print(Primes[i],SET)

    SET.remove(c(Primes[i]))


print(AX)
        
    
    
0