結果
問題 |
No.6 使いものにならないハッシュ
|
ユーザー |
![]() |
提出日時 | 2021-11-01 15:01:13 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 305 ms / 5,000 ms |
コード長 | 863 bytes |
コンパイル時間 | 86 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-10-10 04:14:05 |
合計ジャッジ時間 | 6,239 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
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)