結果

問題 No.688 E869120 and Constructing Array 2
ユーザー YamaKasaYamaKasa
提出日時 2018-07-17 20:28:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 894 bytes
コンパイル時間 3,467 ms
コンパイル使用メモリ 73,812 KB
実行使用メモリ 58,668 KB
最終ジャッジ日時 2023-08-17 14:32:59
合計ジャッジ時間 7,013 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 121 ms
55,628 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 121 ms
56,256 KB
testcase_05 WA -
testcase_06 AC 123 ms
56,016 KB
testcase_07 WA -
testcase_08 AC 123 ms
55,676 KB
testcase_09 WA -
testcase_10 AC 122 ms
55,720 KB
testcase_11 AC 123 ms
55,436 KB
testcase_12 AC 121 ms
55,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long K = scan.nextInt();
		scan.close();
		int index1 = 2;
		int index2 = 0;
		int flag = 0;
		for(int i = 2; i < 30; i++) {
			long x = i * (i - 1);
			index1 = i;
			for(int j = 0; j < 30 - i; j++) {
				long y;
				y = (long)Math.pow(2, j);
				if(x * y == 2 * K) {
					index2 = j;
					flag = 1;
					break;
				}
			}
			if(flag == 1) {
				break;
			}
		}
		System.out.println(index1 + index2);
		for(int i = 0; i < index1; i++) {
			if(i == index1 - 1) {
				System.out.print(1);
			}else {
				System.out.print(1 + " ");
			}
		}
		for(int i = 1; i < index2; i++) {
			if(i == 1) {
				System.out.print(" " + 0 + " ");
			}
			if(i == index2 - 1) {
				System.out.print(0);
			}else {
				System.out.print(0 + " ");
			}
		}
		System.out.println();
	}
}
0