結果

問題 No.680 作れる数
ユーザー maimai
提出日時 2018-04-27 23:39:47
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 260 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 11,468 KB
実行使用メモリ 15,408 KB
最終ジャッジ日時 2023-09-10 06:59:52
合計ジャッジ時間 3,260 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,160 KB
testcase_01 WA -
testcase_02 AC 77 ms
15,256 KB
testcase_03 AC 79 ms
15,080 KB
testcase_04 AC 79 ms
15,288 KB
testcase_05 WA -
testcase_06 AC 79 ms
15,152 KB
testcase_07 WA -
testcase_08 AC 77 ms
15,132 KB
testcase_09 AC 78 ms
15,296 KB
testcase_10 WA -
testcase_11 AC 75 ms
15,120 KB
testcase_12 AC 78 ms
15,172 KB
testcase_13 WA -
testcase_14 AC 78 ms
15,008 KB
testcase_15 WA -
testcase_16 AC 80 ms
15,152 KB
testcase_17 WA -
testcase_18 AC 82 ms
15,116 KB
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def say(s);puts s;exit 0;end

n = gets.to_i
say "YES" if n == 1
say "NO"  if n == 0

last = nil

while n > 0
    l = n.bit_length
    #p [n,(1 << l)-1]
    x = (1 << l)-1
    say "YES" if x == n && last != l
    n -= (1 << (l-1))-1
    last = l-1
end

say "NO"
0