結果

問題 No.187 中華風 (Hard)
ユーザー cielciel
提出日時 2018-11-26 00:37:39
言語 Ruby
(3.2.2)
結果
AC  
実行時間 217 ms / 3,000 ms
コード長 207 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 11,132 KB
実行使用メモリ 26,272 KB
最終ジャッジ日時 2023-08-26 20:49:57
合計ジャッジ時間 5,830 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
15,316 KB
testcase_01 AC 78 ms
15,324 KB
testcase_02 AC 105 ms
20,272 KB
testcase_03 AC 100 ms
20,192 KB
testcase_04 AC 215 ms
25,940 KB
testcase_05 AC 212 ms
26,124 KB
testcase_06 AC 209 ms
25,900 KB
testcase_07 AC 208 ms
25,740 KB
testcase_08 AC 199 ms
26,272 KB
testcase_09 AC 217 ms
26,224 KB
testcase_10 AC 217 ms
25,920 KB
testcase_11 AC 210 ms
25,888 KB
testcase_12 AC 210 ms
25,800 KB
testcase_13 AC 79 ms
15,340 KB
testcase_14 AC 81 ms
15,316 KB
testcase_15 AC 111 ms
18,872 KB
testcase_16 AC 99 ms
18,668 KB
testcase_17 AC 74 ms
15,264 KB
testcase_18 AC 77 ms
15,168 KB
testcase_19 AC 86 ms
15,112 KB
testcase_20 AC 160 ms
23,920 KB
testcase_21 AC 72 ms
15,048 KB
testcase_22 AC 209 ms
25,536 KB
testcase_23 AC 86 ms
15,120 KB
testcase_24 AC 87 ms
15,256 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]
(b-=a)%g>0&&break
n*=m/g
[(a+b/g*x*m)%n,n]})?r[r[0]>0?0:1]%(10**9+7):-1
0