結果

問題 No.501 穴と文字列
ユーザー YamaKasaYamaKasa
提出日時 2018-09-24 16:02:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 840 bytes
コンパイル時間 2,249 ms
コンパイル使用メモリ 77,216 KB
実行使用メモリ 57,560 KB
最終ジャッジ日時 2023-10-22 03:21:20
合計ジャッジ時間 6,342 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
57,456 KB
testcase_01 AC 150 ms
57,540 KB
testcase_02 AC 131 ms
57,436 KB
testcase_03 AC 132 ms
57,444 KB
testcase_04 AC 132 ms
57,300 KB
testcase_05 AC 133 ms
57,448 KB
testcase_06 AC 134 ms
57,412 KB
testcase_07 AC 132 ms
57,468 KB
testcase_08 AC 133 ms
57,504 KB
testcase_09 AC 134 ms
57,400 KB
testcase_10 AC 133 ms
55,524 KB
testcase_11 AC 133 ms
57,372 KB
testcase_12 AC 134 ms
57,424 KB
testcase_13 AC 134 ms
57,420 KB
testcase_14 AC 135 ms
57,548 KB
testcase_15 AC 135 ms
57,560 KB
testcase_16 AC 132 ms
57,320 KB
testcase_17 AC 134 ms
57,416 KB
testcase_18 AC 155 ms
57,416 KB
testcase_19 AC 144 ms
57,420 KB
testcase_20 AC 157 ms
57,440 KB
testcase_21 AC 145 ms
57,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int D = scan.nextInt();
		scan.close();
		if(N == D) {
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < N; i++) {
				sb.append("A");
			}
			System.out.println(sb.toString());
		}else if(N > D){
			int k = N - D;
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < D; i++) {
				sb.append("A");
			}
			for(int i = 0; i < k; i++) {
				sb.append("C");
			}
			System.out.println(sb.toString());
		}else {
			int k1 = D - N;
			int k2 = 2 * N - D;
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < k2; i++) {
				sb.append("A");
			}
			for(int i = 0; i < k1; i++) {
				sb.append("B");
			}
			System.out.println(sb.toString());
		}
	}
}
0