結果

問題 No.501 穴と文字列
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-13 23:06:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 2,884 ms
コンパイル使用メモリ 72,204 KB
実行使用メモリ 56,368 KB
最終ジャッジ日時 2023-08-21 02:04:50
合計ジャッジ時間 6,245 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
56,256 KB
testcase_01 AC 139 ms
55,784 KB
testcase_02 AC 125 ms
56,120 KB
testcase_03 AC 124 ms
55,692 KB
testcase_04 AC 124 ms
55,668 KB
testcase_05 AC 125 ms
55,888 KB
testcase_06 AC 126 ms
55,844 KB
testcase_07 AC 127 ms
55,952 KB
testcase_08 AC 126 ms
56,132 KB
testcase_09 AC 123 ms
55,904 KB
testcase_10 AC 125 ms
55,952 KB
testcase_11 AC 124 ms
56,008 KB
testcase_12 AC 125 ms
55,692 KB
testcase_13 AC 126 ms
55,696 KB
testcase_14 AC 126 ms
56,076 KB
testcase_15 AC 125 ms
56,068 KB
testcase_16 AC 126 ms
55,764 KB
testcase_17 AC 124 ms
55,820 KB
testcase_18 AC 137 ms
55,896 KB
testcase_19 AC 140 ms
56,128 KB
testcase_20 AC 141 ms
54,260 KB
testcase_21 AC 138 ms
56,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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