結果

問題 No.187 中華風 (Hard)
ユーザー cielciel
提出日時 2015-04-20 15:11:52
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 346 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 11,360 KB
実行使用メモリ 26,804 KB
最終ジャッジ日時 2023-09-18 00:52:00
合計ジャッジ時間 5,328 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,340 KB
testcase_01 AC 85 ms
15,288 KB
testcase_02 AC 112 ms
20,544 KB
testcase_03 AC 114 ms
20,516 KB
testcase_04 AC 205 ms
26,488 KB
testcase_05 AC 206 ms
26,788 KB
testcase_06 AC 203 ms
26,452 KB
testcase_07 AC 202 ms
26,212 KB
testcase_08 AC 212 ms
26,804 KB
testcase_09 AC 211 ms
26,676 KB
testcase_10 AC 210 ms
26,588 KB
testcase_11 AC 205 ms
26,720 KB
testcase_12 AC 206 ms
26,596 KB
testcase_13 AC 85 ms
15,352 KB
testcase_14 AC 83 ms
15,136 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 79 ms
15,112 KB
testcase_18 AC 83 ms
15,252 KB
testcase_19 AC 79 ms
15,100 KB
testcase_20 AC 174 ms
24,280 KB
testcase_21 AC 81 ms
15,132 KB
testcase_22 AC 206 ms
26,320 KB
testcase_23 AC 79 ms
15,128 KB
testcase_24 AC 79 ms
15,132 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:10: warning: assigned but unused variable - y
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
def egcd(x,y)
	return [x,1,0] if y==0
	g,a,b=egcd(y,x%y)
	[g,b,a-x/y*b]
end
def chinese(a)
	return nil if !a||a.empty?
	a.reduce([0,1]){|(a1,m1),(a2,m2)|
		g,x,y=egcd(m1,m2)
		v=(a2-a1)/g
		break if v*g!=a2-a1
		lcm=m1/g*m2
		[(a1+v*x*m1)%lcm,lcm]
	}
end
r=chinese($<.drop(1).map{|e|e.split.map &:to_i})
p r ? r[0]%1000000007 : -1
0