結果

問題 No.6 使いものにならないハッシュ
ユーザー tabataba
提出日時 2016-04-13 00:03:12
言語 Python2
(2.7.18)
結果
AC  
実行時間 2,351 ms / 5,000 ms
コード長 527 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 6,704 KB
実行使用メモリ 12,540 KB
最終ジャッジ日時 2023-10-14 23:00:58
合計ジャッジ時間 26,031 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,172 KB
testcase_01 AC 11 ms
5,996 KB
testcase_02 AC 2,351 ms
12,540 KB
testcase_03 AC 143 ms
6,836 KB
testcase_04 AC 226 ms
7,364 KB
testcase_05 AC 340 ms
7,912 KB
testcase_06 AC 814 ms
9,268 KB
testcase_07 AC 355 ms
7,728 KB
testcase_08 AC 651 ms
8,684 KB
testcase_09 AC 195 ms
6,716 KB
testcase_10 AC 11 ms
6,136 KB
testcase_11 AC 170 ms
7,008 KB
testcase_12 AC 1,200 ms
10,320 KB
testcase_13 AC 104 ms
6,468 KB
testcase_14 AC 192 ms
6,964 KB
testcase_15 AC 831 ms
9,316 KB
testcase_16 AC 444 ms
7,980 KB
testcase_17 AC 1,276 ms
10,316 KB
testcase_18 AC 2,128 ms
12,264 KB
testcase_19 AC 1,234 ms
10,136 KB
testcase_20 AC 1,053 ms
9,836 KB
testcase_21 AC 79 ms
6,680 KB
testcase_22 AC 1,145 ms
10,120 KB
testcase_23 AC 1,100 ms
10,168 KB
testcase_24 AC 1,083 ms
10,024 KB
testcase_25 AC 446 ms
8,128 KB
testcase_26 AC 1,502 ms
10,708 KB
testcase_27 AC 910 ms
9,540 KB
testcase_28 AC 502 ms
8,416 KB
testcase_29 AC 1,669 ms
11,280 KB
testcase_30 AC 1,441 ms
10,812 KB
testcase_31 AC 1,144 ms
9,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
k=input()
n=input()
def hash(a):
	a=sum(int(i)for i in`a`)
	return a if a<10 else hash(a)
def isprime(a):
	if a<2:return False
	if a==2:return True
	s=math.sqrt(a)
	for i in range(2,int(s)+2):
		if a%i==0:
			return False
	return True
p=[i for i in range(k,n+1)if isprime(i)]
h=[hash(i)for i in p]
l=[0]*len(p)
m=-1
#print p
#print h
for i in range(len(p)):
	for j in range(i+1,len(p)+1):
		t=h[i:j]
		s=set(t)
		if len(t)==len(s):
			l[i]=j-i
			if l[i]>=l[m]:
				m=i
		else:
			break
#print l
#print m
print p[m]
0