結果

問題 No.688 E869120 and Constructing Array 2
ユーザー maimai
提出日時 2018-05-18 22:42:36
言語 Ruby
(3.2.2)
結果
AC  
実行時間 79 ms / 1,000 ms
コード長 347 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 11,324 KB
実行使用メモリ 15,264 KB
最終ジャッジ日時 2023-09-21 19:56:18
合計ジャッジ時間 2,363 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,240 KB
testcase_01 AC 78 ms
15,156 KB
testcase_02 AC 78 ms
15,104 KB
testcase_03 AC 79 ms
15,264 KB
testcase_04 AC 77 ms
15,084 KB
testcase_05 AC 78 ms
15,096 KB
testcase_06 AC 78 ms
15,148 KB
testcase_07 AC 77 ms
15,240 KB
testcase_08 AC 78 ms
15,100 KB
testcase_09 AC 76 ms
15,028 KB
testcase_10 AC 78 ms
15,052 KB
testcase_11 AC 78 ms
15,044 KB
testcase_12 AC 77 ms
15,100 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def calc(zero, one)
    (1 << zero)*(one*(one-1)/2)
end


K = gets.to_i

if K == 0
    puts "1\n0"; exit
end
if K == 1
    puts "2\n1 1"; exit
end

3.upto(30) do |n|
    2.upto(n) do |x|
        k = calc(n-x,x)
        if k == K
            p n
            puts ([0]*(n-x)+[1]*x)*" "
            exit
        end
    end
end

puts "ほげー!"
0