結果

問題 No.688 E869120 and Constructing Array 2
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-05-18 23:02:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,080 bytes
コンパイル時間 4,043 ms
コンパイル使用メモリ 81,400 KB
実行使用メモリ 58,496 KB
最終ジャッジ日時 2023-09-21 20:02:31
合計ジャッジ時間 7,992 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import static java.lang.System.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		Map<Integer,Integer> map = new TreeMap<>();
		for (int i=2; i<=30; i++) {
			map.put(i*(i-1)/2, i);
		}

		List<Integer> ans = new ArrayList<>();

		long n = sc.nextLong();
		if (n == 0) out.println(1);
		if (map.containsKey((int)n)) {
			for (int i=0; i<map.get((int)n); i++) {
				ans.add(1);
			}
			printList(ans);
		}
		else {
			for (Map.Entry<Integer,Integer> e: map.entrySet()) {
				if (is2n(n/e.getKey())) {
					
					for (int i=0; i<map.get(e.getKey()); i++) {
						ans.add(1);
					}
					long t = n/e.getKey();
					while (t%2 == 0) {
						t /= 2;
						ans.add(0);
					}
					printList(ans);
					
					t = n/e.getKey();
					break;
				}
			}
		}
	}

	static void printList(List<Integer> list) {
		for (int i=0; i<list.size(); i++) {
			out.print((i==0?"":" ")+list.get(i));
		}
	}

	static boolean is2n(long l) {
		while (l%2 == 0) {
			l /= 2;
		}
		if (l == 1) return true;
		return false;
	}
}
0