結果

問題 No.187 中華風 (Hard)
ユーザー cielciel
提出日時 2015-04-20 17:36:45
言語 Ruby
(3.3.0)
結果
AC  
実行時間 218 ms / 3,000 ms
コード長 209 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 11,520 KB
実行使用メモリ 26,256 KB
最終ジャッジ日時 2023-08-27 05:32:23
合計ジャッジ時間 5,400 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,032 KB
testcase_01 AC 87 ms
15,224 KB
testcase_02 AC 138 ms
20,064 KB
testcase_03 AC 119 ms
20,196 KB
testcase_04 AC 213 ms
25,900 KB
testcase_05 AC 210 ms
25,948 KB
testcase_06 AC 208 ms
25,792 KB
testcase_07 AC 210 ms
25,636 KB
testcase_08 AC 218 ms
26,044 KB
testcase_09 AC 216 ms
26,256 KB
testcase_10 AC 215 ms
25,732 KB
testcase_11 AC 209 ms
25,860 KB
testcase_12 AC 212 ms
26,004 KB
testcase_13 AC 87 ms
15,048 KB
testcase_14 AC 86 ms
15,240 KB
testcase_15 AC 109 ms
18,804 KB
testcase_16 AC 110 ms
18,652 KB
testcase_17 AC 84 ms
15,244 KB
testcase_18 AC 86 ms
15,224 KB
testcase_19 AC 84 ms
15,228 KB
testcase_20 AC 178 ms
23,940 KB
testcase_21 AC 84 ms
15,244 KB
testcase_22 AC 207 ms
25,548 KB
testcase_23 AC 83 ms
14,992 KB
testcase_24 AC 84 ms
14,984 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:6: warning: assigned but unused variable - y
Syntax OK

ソースコード

diff #

f=->x,y{return[x,1,0]if y==0
g,a,b=f[y,x%y]
[g,b,a-x/y*b]}
gets
a=$<.map{|e|e.split.map &:to_i}
p (r=a.reduce{|(a,m),(b,n)|g,x,y=f[m,n]
break if(b-=a)%g>0
n*=m/g
[(a+b/g*x*m)%n,n]})?r[~(0<=>r[0])]%(10**9+7):-1
0