結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー ks2mks2m
提出日時 2019-08-30 23:06:31
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,161 bytes
コンパイル時間 2,164 ms
コンパイル使用メモリ 75,896 KB
実行使用メモリ 49,904 KB
最終ジャッジ日時 2023-09-06 07:05:31
合計ジャッジ時間 5,410 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 45 ms
49,268 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 42 ms
49,368 KB
testcase_06 AC 43 ms
49,548 KB
testcase_07 AC 43 ms
49,256 KB
testcase_08 AC 44 ms
49,324 KB
testcase_09 AC 43 ms
49,520 KB
testcase_10 AC 41 ms
49,340 KB
testcase_11 AC 41 ms
49,172 KB
testcase_12 AC 42 ms
49,536 KB
testcase_13 AC 44 ms
49,588 KB
testcase_14 AC 43 ms
49,224 KB
testcase_15 AC 43 ms
49,660 KB
testcase_16 AC 43 ms
49,536 KB
testcase_17 AC 43 ms
49,424 KB
testcase_18 AC 43 ms
49,208 KB
testcase_19 AC 42 ms
49,436 KB
testcase_20 AC 42 ms
49,100 KB
testcase_21 AC 42 ms
49,416 KB
testcase_22 AC 43 ms
49,432 KB
testcase_23 AC 43 ms
49,440 KB
testcase_24 AC 43 ms
49,636 KB
testcase_25 AC 45 ms
49,772 KB
testcase_26 AC 43 ms
49,460 KB
testcase_27 AC 42 ms
49,216 KB
testcase_28 AC 43 ms
49,288 KB
testcase_29 AC 43 ms
49,368 KB
testcase_30 AC 43 ms
49,852 KB
testcase_31 AC 42 ms
49,228 KB
testcase_32 AC 43 ms
49,296 KB
testcase_33 AC 44 ms
49,696 KB
testcase_34 AC 44 ms
49,400 KB
testcase_35 AC 44 ms
49,388 KB
testcase_36 AC 44 ms
49,452 KB
testcase_37 AC 44 ms
49,268 KB
testcase_38 AC 43 ms
49,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		br.close();

		if (n == 32) {
			System.out.println("01011010");
			return;
		}

		List<Integer> list = new ArrayList<>();
		while (n > 0) {
			int n2 = (int) Math.sqrt(n);
			list.add(n2);
			n -= n2 * n2;
		}

		StringBuilder sb = new StringBuilder();
		for (int i = list.size() - 1; i >= 0; i--) {
			if (list.get(i) % 2 == 1) {
				sb.append(make(list.get(i), 0));
			}
		}

		int start = 0;
		for (int i = 0; i < list.size(); i++) {
			if (list.get(i) % 2 == 0) {
				sb.append(make(list.get(i), start));
				start ^= 1;
			}
		}
		System.out.println(sb.toString());
	}

	static String make(int len, int start) {
		StringBuilder sb = new StringBuilder();
		int s1 = start;
		int s2 = start ^ 1;
		for (int i = 0; i < len / 2; i++) {
			sb.append(s1).append(s2);
		}
		if (len % 2 == 1) {
			sb.append(s1);
		}
		return sb.toString();
	}
}
0