結果

問題 No.688 E869120 and Constructing Array 2
ユーザー GrenacheGrenache
提出日時 2018-05-18 22:35:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 986 bytes
コンパイル時間 5,574 ms
コンパイル使用メモリ 74,800 KB
実行使用メモリ 56,464 KB
最終ジャッジ日時 2023-09-21 19:53:46
合計ジャッジ時間 8,216 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,652 KB
testcase_01 AC 116 ms
55,780 KB
testcase_02 AC 116 ms
55,536 KB
testcase_03 WA -
testcase_04 AC 118 ms
55,792 KB
testcase_05 AC 121 ms
55,840 KB
testcase_06 AC 120 ms
53,760 KB
testcase_07 AC 119 ms
55,944 KB
testcase_08 AC 121 ms
56,096 KB
testcase_09 AC 119 ms
56,236 KB
testcase_10 AC 119 ms
55,944 KB
testcase_11 AC 120 ms
55,904 KB
testcase_12 AC 121 ms
56,244 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();

		for (int i = 0; true; i++) {
			int tmp = (int)Math.sqrt(k * 2);
			if (tmp * (tmp + 1) == k * 2) {
				int cnt = tmp + 1 + i;

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

				return;
			}

			k /= 2;
		}
	}

	// ---------------------------------------------------
	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