結果

問題 No.683 Two Operations No.3
ユーザー cympfhcympfh
提出日時 2018-05-19 21:11:25
言語 Ruby
(3.2.2)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 11,568 KB
実行使用メモリ 15,332 KB
最終ジャッジ日時 2023-09-10 23:48:56
合計ジャッジ時間 2,224 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,192 KB
testcase_01 AC 81 ms
15,148 KB
testcase_02 AC 80 ms
15,036 KB
testcase_03 AC 80 ms
15,244 KB
testcase_04 AC 78 ms
15,108 KB
testcase_05 AC 80 ms
15,064 KB
testcase_06 AC 81 ms
15,112 KB
testcase_07 AC 80 ms
15,096 KB
testcase_08 AC 81 ms
15,316 KB
testcase_09 AC 80 ms
15,332 KB
testcase_10 AC 80 ms
15,288 KB
testcase_11 AC 80 ms
15,152 KB
testcase_12 AC 79 ms
15,136 KB
testcase_13 AC 80 ms
15,036 KB
testcase_14 AC 79 ms
15,284 KB
testcase_15 AC 80 ms
15,096 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def good(n,m)
  if n == 0 or m == 0
    :Yes
  elsif n < 0 or m < 0
    :No
  elsif n.odd? and m.odd?
    :No
  elsif n.even? and m.even?
    if good(n/2, m-1) == :Yes or good(n-1, m/2) == :Yes
      :Yes
    else
      :No
    end
  elsif n.even?
    good(n/2, m-1)
  else
    good(n-1, m/2)
  end
end

n,m=gets.split.map(&:to_i)
puts good(n,m)
0