結果

問題 No.187 中華風 (Hard)
ユーザー cielciel
提出日時 2015-04-20 15:24:26
言語 Ruby
(3.3.0)
結果
AC  
実行時間 211 ms / 3,000 ms
コード長 230 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 11,384 KB
実行使用メモリ 26,672 KB
最終ジャッジ日時 2023-09-18 00:54:28
合計ジャッジ時間 4,848 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,180 KB
testcase_01 AC 83 ms
15,336 KB
testcase_02 AC 116 ms
20,128 KB
testcase_03 AC 112 ms
20,204 KB
testcase_04 AC 202 ms
25,700 KB
testcase_05 AC 202 ms
25,800 KB
testcase_06 AC 202 ms
25,292 KB
testcase_07 AC 201 ms
25,516 KB
testcase_08 AC 211 ms
26,672 KB
testcase_09 AC 210 ms
26,584 KB
testcase_10 AC 211 ms
26,220 KB
testcase_11 AC 203 ms
25,708 KB
testcase_12 AC 204 ms
25,736 KB
testcase_13 AC 82 ms
15,236 KB
testcase_14 AC 83 ms
15,172 KB
testcase_15 AC 106 ms
18,696 KB
testcase_16 AC 106 ms
18,676 KB
testcase_17 AC 81 ms
15,140 KB
testcase_18 AC 84 ms
15,280 KB
testcase_19 AC 81 ms
15,168 KB
testcase_20 AC 172 ms
24,084 KB
testcase_21 AC 80 ms
15,116 KB
testcase_22 AC 199 ms
25,488 KB
testcase_23 AC 81 ms
15,032 KB
testcase_24 AC 82 ms
15,216 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:5: 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]}
a=$<.drop(1).map{|e|e.split.map &:to_i}
p (r=a.reduce([0,1]){|(a,m),(b,n)|g,x,y=f[m,n]
break if(v=(b-=a)/g)*g!=b
n*=m/g
[(a+v*x*m)%n,n]})?(r[0]==0?r[1]:r[0])%1000000007:-1
0