結果

問題 No.501 穴と文字列
ユーザー 37zigen37zigen
提出日時 2017-04-07 22:54:11
言語 Java19
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 71,672 KB
実行使用メモリ 58,344 KB
最終ジャッジ日時 2023-08-21 07:08:03
合計ジャッジ時間 5,853 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,484 KB
testcase_01 AC 132 ms
55,984 KB
testcase_02 AC 119 ms
56,276 KB
testcase_03 AC 119 ms
56,036 KB
testcase_04 AC 118 ms
58,344 KB
testcase_05 AC 118 ms
56,064 KB
testcase_06 AC 120 ms
58,320 KB
testcase_07 AC 120 ms
56,264 KB
testcase_08 AC 119 ms
56,004 KB
testcase_09 AC 122 ms
56,504 KB
testcase_10 AC 120 ms
55,956 KB
testcase_11 AC 120 ms
55,936 KB
testcase_12 AC 121 ms
56,160 KB
testcase_13 AC 119 ms
55,868 KB
testcase_14 AC 121 ms
56,172 KB
testcase_15 AC 120 ms
55,964 KB
testcase_16 AC 121 ms
56,040 KB
testcase_17 AC 122 ms
56,156 KB
testcase_18 AC 135 ms
56,424 KB
testcase_19 AC 135 ms
55,516 KB
testcase_20 AC 135 ms
55,904 KB
testcase_21 AC 133 ms
56,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		StringBuilder as = new StringBuilder();
		if (D % 2 == 1) {
			as.append("A");
			--D;
			--N;
		}

		// 穴の数D
		// 文字数N

		StringBuilder bs = new StringBuilder();
		StringBuilder cs = new StringBuilder();
		while (N > 0) {
			while (D > N) {
				bs.append("B");
				D -= 2;
				--N;
			}
			while (D > 0) {
				as.append("A");
				--D;
				--N;
			}

			while (N > 0) {
				cs.append("C");
				--N;
			}
		}

		System.out.println(as.append(bs).append(cs));
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0