結果
問題 | No.1113 二つの整数 / Two Integers |
ユーザー |
|
提出日時 | 2020-11-10 18:43:48 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 79 ms / 1,000 ms |
コード長 | 1,310 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-07-22 18:04:58 |
合計ジャッジ時間 | 2,495 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 |
コンパイルメッセージ
Syntax OK
ソースコード
DEBUG = trueMOD = 10**9+7YESNO = %w(Odd Even)def square?(n)ac, wa = 0, n+1while ac + 1 < wawj = (ac + wa) / 2case wj*wj <=> nwhen -1ac = wjwhen 1wa = wjelsereturn trueendendfalseenddef main@A, @B = intsn = gcd(@A, @B)yesno square?(n)enddef int; gets.to_i; enddef ints; gets.split.map &:to_i; enddef array(&convert); gets.split.map(&convert); enddef string; gets.chomp; enddef rep(n, &b); Array.new(n, &b); enddef yes; puts YESNO[0]; enddef no; puts YESNO[1]; enddef yesno t; t ? yes : no; enddef max(*xs); xs.max; enddef min(*xs); xs.max; enddef minmax(*xs); xs.minmax; enddef matrix(h, w, fill=nil); Array.new(h) { [fill] * w }; enddef debug(x); STDERR.puts x.inspect if DEBUG; enddef gcd(*xs); xs.inject(0) { |y, x| y.gcd(x) }; enddef factorial(n, mod); (2..n).inject(1) { |f, x| f * x % mod }; enddef cumsum(xs); ys = [0]; xs.each { |x| ys << x + ys[-1] }; ys; enddef cumdiff(ys); xs = []; xs.inject { |x, y| xs << (d = y - x); d }; enddef cumfold(ys, range); r = range.end; r -= 1 if range.exclusive_end?; ys[r] - ys[range.begin-1]; enddef mod_inv(x, mod); x.pow(mod-2, mod); enddef mod_div(x, y, mod); x * mod_inv(y, mod) % mod; enddef bitbrute(size, block); (1<<size).times(&block); endmain