結果

問題 No.6 使いものにならないハッシュ
ユーザー ayame_pyayame_py
提出日時 2015-10-08 15:26:49
言語 Python2
(2.7.18)
結果
AC  
実行時間 2,463 ms / 5,000 ms
コード長 844 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 6,712 KB
実行使用メモリ 12,316 KB
最終ジャッジ日時 2023-10-14 22:56:43
合計ジャッジ時間 35,531 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,084 KB
testcase_01 AC 10 ms
6,108 KB
testcase_02 AC 2,463 ms
12,316 KB
testcase_03 AC 208 ms
6,968 KB
testcase_04 AC 407 ms
7,180 KB
testcase_05 AC 444 ms
7,688 KB
testcase_06 AC 1,191 ms
9,012 KB
testcase_07 AC 683 ms
7,664 KB
testcase_08 AC 1,086 ms
8,452 KB
testcase_09 AC 431 ms
6,984 KB
testcase_10 AC 12 ms
6,104 KB
testcase_11 AC 242 ms
7,084 KB
testcase_12 AC 1,375 ms
10,136 KB
testcase_13 AC 247 ms
6,552 KB
testcase_14 AC 429 ms
7,000 KB
testcase_15 AC 1,097 ms
9,076 KB
testcase_16 AC 874 ms
7,776 KB
testcase_17 AC 1,880 ms
10,212 KB
testcase_18 AC 2,330 ms
12,020 KB
testcase_19 AC 1,807 ms
10,112 KB
testcase_20 AC 1,494 ms
9,796 KB
testcase_21 AC 112 ms
6,684 KB
testcase_22 AC 1,675 ms
9,820 KB
testcase_23 AC 1,421 ms
9,956 KB
testcase_24 AC 1,556 ms
9,864 KB
testcase_25 AC 813 ms
7,884 KB
testcase_26 AC 2,011 ms
10,744 KB
testcase_27 AC 1,473 ms
9,328 KB
testcase_28 AC 780 ms
8,352 KB
testcase_29 AC 2,198 ms
11,168 KB
testcase_30 AC 1,743 ms
10,576 KB
testcase_31 AC 1,616 ms
9,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:utf-8
import math
def hashf(n):
	while int(math.log10(n))!=0:
		m = int(math.log10(n)) + 1
		temp = 0
		for i in range(1, m+1):
			t = n%10
			temp += t
			n -= t
			n /= 10
		n = temp
	return n

def prime(k, n):
	res = []
	if k<=2 and 2<=n: res.append(2)
	for i in range(max(k, 2), n+1):
		for j in range(2, int(math.sqrt(i))+2):
			if i % j == 0:
				break
			if j == int(math.sqrt(i)+1):
				res.append(i)
	return res

k = int(raw_input())
n = int(raw_input())

array = prime(k, n)

array_hash = list(array)
for i in range(len(array)):
	array_hash[i] = hashf(array_hash[i])

inum = [0 for _ in range(10)]
leng = 0
ans = 0
r = 0

for l in range(len(array_hash)):
	while(r < len(array_hash) and inum[array_hash[r]]==0):
		inum[array_hash[r]]+=1
		r+=1
	if leng <= r-l:
		leng = r-l
		ans = array[l]
	inum[array_hash[l]]-=1

print ans
0