結果

問題 No.688 E869120 and Constructing Array 2
ユーザー finefine
提出日時 2018-05-18 22:30:42
言語 Ruby
(3.3.0)
結果
AC  
実行時間 79 ms / 1,000 ms
コード長 473 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 11,396 KB
実行使用メモリ 15,388 KB
最終ジャッジ日時 2023-09-21 19:50:42
合計ジャッジ時間 2,642 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,236 KB
testcase_01 AC 79 ms
15,252 KB
testcase_02 AC 77 ms
15,096 KB
testcase_03 AC 78 ms
15,232 KB
testcase_04 AC 77 ms
15,164 KB
testcase_05 AC 76 ms
15,216 KB
testcase_06 AC 75 ms
15,388 KB
testcase_07 AC 76 ms
15,016 KB
testcase_08 AC 76 ms
15,136 KB
testcase_09 AC 76 ms
15,132 KB
testcase_10 AC 77 ms
15,304 KB
testcase_11 AC 77 ms
15,104 KB
testcase_12 AC 77 ms
15,012 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

k = gets.to_i
if k == 0
    puts 1
    puts "0"
    exit
end
2.upto(30) do |i|
    hoge = i * (i - 1) / 2
    if k % hoge != 0
        next
    end
    cnt = 0
    tmp = k / hoge
    while tmp % 2 == 0
        cnt += 1
        tmp /= 2
    end
    if tmp == 1 && cnt + i <= 30
        puts cnt + i
        a = []
        cnt.times do 
            a.push(0)
        end
        i.times do 
            a.push(1)
        end
        puts a.join(' ')
        break
    end
end
0