結果

問題 No.501 穴と文字列
ユーザー htensaihtensai
提出日時 2019-11-17 20:58:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 2,493 ms
コンパイル使用メモリ 79,096 KB
実行使用メモリ 57,660 KB
最終ジャッジ日時 2023-10-25 21:31:48
合計ジャッジ時間 6,872 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
57,624 KB
testcase_01 AC 134 ms
57,536 KB
testcase_02 AC 123 ms
57,548 KB
testcase_03 AC 121 ms
57,596 KB
testcase_04 AC 121 ms
57,360 KB
testcase_05 AC 120 ms
57,332 KB
testcase_06 AC 124 ms
57,584 KB
testcase_07 AC 123 ms
57,600 KB
testcase_08 AC 123 ms
57,648 KB
testcase_09 AC 122 ms
57,548 KB
testcase_10 AC 122 ms
57,516 KB
testcase_11 AC 120 ms
57,284 KB
testcase_12 AC 123 ms
57,660 KB
testcase_13 AC 122 ms
57,260 KB
testcase_14 AC 120 ms
57,372 KB
testcase_15 AC 110 ms
56,276 KB
testcase_16 AC 123 ms
57,652 KB
testcase_17 AC 120 ms
57,184 KB
testcase_18 AC 121 ms
56,280 KB
testcase_19 AC 147 ms
57,340 KB
testcase_20 AC 138 ms
57,652 KB
testcase_21 AC 138 ms
57,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
 	public static void main (String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		if (d > n) {
		    for (int i = 0; i < n; i++) {
		        if (i < n - (d - n)) {
		            sb.append("A");
		        } else {
		            sb.append("B");
		        }
		    }
		} else {
		    for (int i = 0; i < n; i++) {
		        if (i < d) {
		            sb.append("A");
		        } else {
		            sb.append("C");
		        }
		    }
		}
		System.out.println(sb);
	}
}


0