結果

問題 No.6 使いものにならないハッシュ
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-31 17:52:00
言語 Ruby
(3.3.0)
結果
AC  
実行時間 200 ms / 5,000 ms
コード長 450 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 17,348 KB
最終ジャッジ日時 2023-10-14 23:11:23
合計ジャッジ時間 6,345 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
15,280 KB
testcase_01 AC 89 ms
15,212 KB
testcase_02 AC 200 ms
17,348 KB
testcase_03 AC 109 ms
16,044 KB
testcase_04 AC 119 ms
16,076 KB
testcase_05 AC 130 ms
16,736 KB
testcase_06 AC 161 ms
16,816 KB
testcase_07 AC 141 ms
16,784 KB
testcase_08 AC 154 ms
16,548 KB
testcase_09 AC 132 ms
16,404 KB
testcase_10 AC 88 ms
15,248 KB
testcase_11 AC 110 ms
16,112 KB
testcase_12 AC 172 ms
17,052 KB
testcase_13 AC 127 ms
16,320 KB
testcase_14 AC 133 ms
16,244 KB
testcase_15 AC 162 ms
17,068 KB
testcase_16 AC 146 ms
16,624 KB
testcase_17 AC 173 ms
17,040 KB
testcase_18 AC 193 ms
17,316 KB
testcase_19 AC 167 ms
16,948 KB
testcase_20 AC 165 ms
16,872 KB
testcase_21 AC 100 ms
15,728 KB
testcase_22 AC 167 ms
16,924 KB
testcase_23 AC 168 ms
16,820 KB
testcase_24 AC 169 ms
17,020 KB
testcase_25 AC 144 ms
16,852 KB
testcase_26 AC 176 ms
16,900 KB
testcase_27 AC 160 ms
16,964 KB
testcase_28 AC 135 ms
16,436 KB
testcase_29 AC 179 ms
17,084 KB
testcase_30 AC 175 ms
16,892 KB
testcase_31 AC 166 ms
16,860 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'

def f(n)
	re=0
	n.to_s.chars{|e|
		re+=e.to_i
	}
	return re
end

d=gets.to_i
u=gets.to_i
x=Prime.each(u).to_a
while x[0]<d
	x.shift
end

x=x.map{|e|
	e2=e
	while e2>9
		e2=f(e2)
	end
	[e,e2]
}
anslen=1
ans=x[0]
while x.empty? == false
	e=x.shift
	e0=e[0]
	e1=e[1]
	hs={}
	hs[e1]=0
	len=1
	x.each{|e2|
		if hs.key?(e2[1])==false
			len+=1
			hs[e2[1]]=0
		else
			break
		end
	}
	if anslen<=len
		ans=e0
		anslen=len
	end
end
puts ans
0