結果

問題 No.3015 アンチローリングハッシュ
ユーザー cielciel
提出日時 2015-11-01 03:28:29
言語 Ruby
(3.3.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 362 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 11,248 KB
実行使用メモリ 15,304 KB
最終ジャッジ日時 2023-10-11 07:40:44
合計ジャッジ時間 3,503 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,032 KB
testcase_01 AC 82 ms
15,304 KB
testcase_02 AC 83 ms
15,144 KB
testcase_03 AC 82 ms
15,120 KB
testcase_04 AC 82 ms
15,208 KB
testcase_05 AC 83 ms
15,256 KB
testcase_06 AC 84 ms
15,264 KB
testcase_07 AC 83 ms
15,092 KB
testcase_08 AC 83 ms
15,088 KB
testcase_09 AC 84 ms
15,116 KB
testcase_10 AC 86 ms
15,196 KB
testcase_11 AC 87 ms
15,184 KB
testcase_12 AC 85 ms
15,272 KB
testcase_13 AC 86 ms
15,012 KB
testcase_14 AC 85 ms
15,200 KB
testcase_15 AC 84 ms
15,004 KB
testcase_16 AC 88 ms
15,096 KB
testcase_17 AC 86 ms
15,200 KB
testcase_18 AC 84 ms
15,224 KB
testcase_19 AC 86 ms
15,200 KB
testcase_20 AC 86 ms
15,212 KB
testcase_21 AC 86 ms
15,132 KB
testcase_22 AC 83 ms
15,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
#cf: http://www.utpc.jp/2012/slides/Uinny.pdf

N=10

def calc(s)
	r=0
	b=1
	s.size.times{|i|
		r=(r+b*s[s.size-i-1].ord)%P
		b=(b*B)%P
	}
	r
end

B,P=$<.read.split.map(&:to_i)
alphabet=[*'a'..'z']
h={}
loop{
	x=N.times.map{alphabet.sample}.join
	v=calc(x)
	if h.has_key?(v)
		if h[v]!=x
			puts h[v]
			puts x
			break
		end
	else
		h[v]=x
	end
}
0