結果

問題 No.638 Sum of "not power of 2"
ユーザー finefine
提出日時 2018-01-26 22:28:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 85 ms / 1,000 ms
コード長 200 bytes
コンパイル時間 59 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 15,316 KB
最終ジャッジ日時 2023-08-28 18:09:20
合計ジャッジ時間 1,920 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,252 KB
testcase_01 AC 77 ms
15,312 KB
testcase_02 AC 77 ms
15,252 KB
testcase_03 AC 77 ms
15,288 KB
testcase_04 AC 77 ms
15,136 KB
testcase_05 AC 77 ms
15,128 KB
testcase_06 AC 77 ms
15,064 KB
testcase_07 AC 80 ms
15,148 KB
testcase_08 AC 81 ms
15,132 KB
testcase_09 AC 81 ms
15,076 KB
testcase_10 AC 79 ms
15,316 KB
testcase_11 AC 77 ms
15,152 KB
testcase_12 AC 78 ms
15,080 KB
testcase_13 AC 77 ms
15,240 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:6: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

x = gets.to_i
if x <= 5
    p -1
else
    if x == 7
        p -1
        exit
    end
    y = x - 3
    if y.to_s(2).count(?1) == 1
        puts "5 #{x - 5}"
    else
        puts "3 #{y}"
    end
end
0