結果

問題 No.688 E869120 and Constructing Array 2
ユーザー Mcpu3Mcpu3
提出日時 2018-09-30 18:16:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 144 ms / 1,000 ms
コード長 580 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 74,644 KB
実行使用メモリ 41,712 KB
最終ジャッジ日時 2024-04-20 13:44:22
合計ジャッジ時間 4,735 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
41,288 KB
testcase_01 AC 136 ms
41,444 KB
testcase_02 AC 138 ms
41,712 KB
testcase_03 AC 139 ms
41,464 KB
testcase_04 AC 131 ms
41,064 KB
testcase_05 AC 120 ms
40,168 KB
testcase_06 AC 122 ms
40,216 KB
testcase_07 AC 135 ms
41,428 KB
testcase_08 AC 133 ms
41,308 KB
testcase_09 AC 120 ms
39,996 KB
testcase_10 AC 136 ms
41,304 KB
testcase_11 AC 136 ms
41,124 KB
testcase_12 AC 144 ms
41,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt(), i, j = 0;
        sc.close();
        for (i = 1; i <= 30; ++i) {
            for (j = 0; j <= 30 - i; ++j) {
                if ((i - 1) * i / 2 * (int)Math.pow(2, j) == K) break;
            }
            if (j != 31 - i) break;
        }
        System.out.println(i + j);
        for (int k = 0; k < i; ++k) System.out.print("1 ");
        for (int l = 0; l < j; ++l) System.out.print("0 ");
    }
}
0