結果

問題 No.501 穴と文字列
ユーザー GrenacheGrenache
提出日時 2017-04-09 11:15:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 796 bytes
コンパイル時間 3,370 ms
コンパイル使用メモリ 72,720 KB
実行使用メモリ 56,156 KB
最終ジャッジ日時 2023-08-21 07:15:23
合計ジャッジ時間 7,070 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
55,652 KB
testcase_01 AC 133 ms
55,388 KB
testcase_02 AC 120 ms
56,096 KB
testcase_03 AC 122 ms
56,032 KB
testcase_04 AC 120 ms
56,040 KB
testcase_05 AC 121 ms
55,952 KB
testcase_06 AC 121 ms
55,612 KB
testcase_07 AC 122 ms
55,848 KB
testcase_08 AC 123 ms
55,684 KB
testcase_09 AC 121 ms
56,156 KB
testcase_10 AC 120 ms
56,156 KB
testcase_11 AC 119 ms
55,972 KB
testcase_12 AC 120 ms
56,068 KB
testcase_13 AC 120 ms
55,408 KB
testcase_14 AC 123 ms
55,872 KB
testcase_15 AC 120 ms
55,380 KB
testcase_16 AC 120 ms
55,760 KB
testcase_17 AC 121 ms
55,952 KB
testcase_18 AC 131 ms
55,568 KB
testcase_19 AC 133 ms
55,728 KB
testcase_20 AC 132 ms
55,892 KB
testcase_21 AC 134 ms
56,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder501 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int d = sc.nextInt();

		int b = Math.max(0, d - n);
		int a = d - 2 * b;
		int c = n - (a + b);

		StringBuilder ret = new StringBuilder();
		while (a-- > 0) {
			ret.append('A');
		}
		while (b-- > 0) {
			ret.append('B');
		}
		while (c-- > 0) {
			ret.append('C');
		}

		pr.println(ret);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0