結果
問題 | No.6 使いものにならないハッシュ |
ユーザー | Hydru |
提出日時 | 2023-01-15 15:58:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 180 ms / 5,000 ms |
コード長 | 1,103 bytes |
コンパイル時間 | 1,398 ms |
コンパイル使用メモリ | 86,900 KB |
実行使用メモリ | 108,608 KB |
最終ジャッジ日時 | 2023-08-27 23:18:42 |
合計ジャッジ時間 | 7,108 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 95 ms
71,760 KB |
testcase_01 | AC | 96 ms
71,244 KB |
testcase_02 | AC | 175 ms
108,396 KB |
testcase_03 | AC | 130 ms
80,532 KB |
testcase_04 | AC | 140 ms
87,776 KB |
testcase_05 | AC | 139 ms
85,688 KB |
testcase_06 | AC | 157 ms
97,220 KB |
testcase_07 | AC | 152 ms
95,044 KB |
testcase_08 | AC | 157 ms
97,464 KB |
testcase_09 | AC | 163 ms
108,512 KB |
testcase_10 | AC | 95 ms
71,248 KB |
testcase_11 | AC | 130 ms
80,324 KB |
testcase_12 | AC | 167 ms
97,248 KB |
testcase_13 | AC | 154 ms
104,996 KB |
testcase_14 | AC | 159 ms
105,292 KB |
testcase_15 | AC | 157 ms
94,644 KB |
testcase_16 | AC | 161 ms
102,824 KB |
testcase_17 | AC | 167 ms
108,608 KB |
testcase_18 | AC | 174 ms
108,528 KB |
testcase_19 | AC | 173 ms
108,124 KB |
testcase_20 | AC | 161 ms
99,976 KB |
testcase_21 | AC | 120 ms
79,304 KB |
testcase_22 | AC | 166 ms
102,824 KB |
testcase_23 | AC | 164 ms
97,196 KB |
testcase_24 | AC | 168 ms
99,980 KB |
testcase_25 | AC | 158 ms
94,952 KB |
testcase_26 | AC | 180 ms
108,336 KB |
testcase_27 | AC | 169 ms
102,956 KB |
testcase_28 | AC | 147 ms
91,104 KB |
testcase_29 | AC | 179 ms
108,164 KB |
testcase_30 | AC | 168 ms
100,068 KB |
testcase_31 | AC | 163 ms
100,176 KB |
ソースコード
# nまでの素数を要素にもつ集合を返す関数 def primesUpTo(n): primes=set(range(2,n+1)) for i in range(2,n): if i in primes: it = i ** 2 while it <= n: if it in primes: primes.remove(it) it += i return primes def digit_hash(n): result=0 while(n!=0): result+=n%10 n//=10 if result<10: return result else: return digit_hash(result) k=int(input()) n=int(input()) P=sorted(list(primesUpTo(n))) from collections import deque Q=deque() cnt=0 max_cnt=0 hash=[0 for _ in range(10)] max_p=0 for i in range(len(P)): p=P[i] if p<k: continue sp=digit_hash(p) if hash[sp]==0: hash[sp]=1 cnt+=1 else: while(True): q=Q.popleft() sq=digit_hash(q) hash[sq]=0 cnt-=1 if sq==sp: hash[sp]=1 cnt+=1 break Q.append(p) if cnt>=max_cnt: max_cnt=cnt max_p=i-cnt+1 print(P[max_p])