結果

問題 No.6 使いものにならないハッシュ
ユーザー ytftytft
提出日時 2022-11-02 14:44:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 5,000 ms
コード長 570 bytes
コンパイル時間 1,201 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 79,940 KB
最終ジャッジ日時 2023-09-24 03:57:02
合計ジャッジ時間 7,079 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
71,580 KB
testcase_01 AC 87 ms
71,644 KB
testcase_02 AC 142 ms
79,848 KB
testcase_03 AC 116 ms
78,028 KB
testcase_04 AC 119 ms
78,232 KB
testcase_05 AC 122 ms
78,288 KB
testcase_06 AC 125 ms
79,152 KB
testcase_07 AC 117 ms
78,880 KB
testcase_08 AC 125 ms
79,288 KB
testcase_09 AC 120 ms
79,472 KB
testcase_10 AC 85 ms
71,408 KB
testcase_11 AC 121 ms
78,280 KB
testcase_12 AC 129 ms
79,304 KB
testcase_13 AC 114 ms
79,292 KB
testcase_14 AC 118 ms
79,476 KB
testcase_15 AC 130 ms
79,284 KB
testcase_16 AC 125 ms
79,224 KB
testcase_17 AC 124 ms
79,428 KB
testcase_18 AC 137 ms
79,916 KB
testcase_19 AC 136 ms
79,716 KB
testcase_20 AC 127 ms
79,296 KB
testcase_21 AC 115 ms
78,088 KB
testcase_22 AC 129 ms
79,436 KB
testcase_23 AC 123 ms
79,156 KB
testcase_24 AC 124 ms
79,248 KB
testcase_25 AC 122 ms
79,136 KB
testcase_26 AC 128 ms
79,940 KB
testcase_27 AC 124 ms
79,400 KB
testcase_28 AC 119 ms
78,560 KB
testcase_29 AC 132 ms
79,888 KB
testcase_30 AC 128 ms
79,660 KB
testcase_31 AC 126 ms
79,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,copy
input=lambda:sys.stdin.readline().rstrip()
def has(a):
	if a<10:
		return a
	temp=0
	while a>0:
		temp+=a%10
		a//=10
	return has(temp)
K=int(input())
N=int(input())
isPrime=[1 for i in range(N+1)]
primes=[]
for i in range(2,N+1):
	if isPrime[i]:
		for j in range(i*2,N+1,i):
			isPrime[j]=0
		if K<=i:
			primes.append(i)
P=[has(i) for i in primes]
big,cur,ans=0,1,0
count=[0 for i in range(10)]
for end in range(len(P)):
	count[P[end]]+=1
	while max(count)>1:
		count[P[big]]-=1
		big+=1
	if cur<=end-big+1:
		cur=end-big+1
		ans=big
print(primes[ans])
0