結果

問題 No.688 E869120 and Constructing Array 2
ユーザー GrenacheGrenache
提出日時 2018-05-18 22:50:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 1,000 ms
コード長 1,116 bytes
コンパイル時間 5,633 ms
コンパイル使用メモリ 74,812 KB
実行使用メモリ 56,036 KB
最終ジャッジ日時 2023-09-21 19:59:41
合計ジャッジ時間 8,187 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,784 KB
testcase_01 AC 129 ms
55,492 KB
testcase_02 AC 127 ms
55,764 KB
testcase_03 AC 128 ms
55,720 KB
testcase_04 AC 127 ms
55,472 KB
testcase_05 AC 129 ms
56,036 KB
testcase_06 AC 129 ms
55,692 KB
testcase_07 AC 128 ms
55,696 KB
testcase_08 AC 128 ms
55,700 KB
testcase_09 AC 125 ms
55,472 KB
testcase_10 AC 129 ms
55,624 KB
testcase_11 AC 126 ms
55,748 KB
testcase_12 AC 126 ms
55,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder688 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int k = sc.nextInt();

		if (k == 0) {
			pr.println(1);
			pr.println(1);

			return;
		}

		for (int i = 0; i <= 30; i++) {
			for (int j = 0; i + j <= 30; j++) {
				long tmp = i * (i - 1) / 2;
				for (int l = 0; l < j; l++) {
					tmp *= 2;
				}

				if (tmp == k) {
					pr.println(i + j);
					for (int jj = 0; jj < i + j; jj++) {
						if (jj > 0) {
							pr.print(' ');
						}
						if (jj < i) {
							pr.print(1);
						} else {
							pr.print(0);
						}
					}
					pr.println();

					return;
				}
			}
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0