結果

問題 No.680 作れる数
ユーザー letrangerjpletrangerjp
提出日時 2018-04-27 23:59:59
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 250 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 11,532 KB
実行使用メモリ 15,404 KB
最終ジャッジ日時 2023-09-10 07:03:56
合計ジャッジ時間 2,821 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,104 KB
testcase_01 AC 79 ms
15,128 KB
testcase_02 AC 80 ms
15,228 KB
testcase_03 AC 80 ms
15,120 KB
testcase_04 WA -
testcase_05 AC 79 ms
15,112 KB
testcase_06 WA -
testcase_07 AC 80 ms
15,152 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 80 ms
15,152 KB
testcase_11 AC 80 ms
15,148 KB
testcase_12 WA -
testcase_13 AC 80 ms
15,028 KB
testcase_14 WA -
testcase_15 AC 79 ms
15,140 KB
testcase_16 WA -
testcase_17 AC 80 ms
15,008 KB
testcase_18 WA -
testcase_19 AC 79 ms
15,204 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i

def check2(l, r)
  while r > 1
    l -= r /= 2
  end
  l == 0
end

def check1(n)
  return true if n == 0
  r1 = n / 2 + 1
  l1 = n - r1
  r2 = n / 2 + 2
  l2 = n - r2
  check2(l1, r1) || check2(l2, r2)
end

puts check1(N) ? :YES : :NO
0