結果

問題 No.501 穴と文字列
ユーザー samplelpmassamplelpmas
提出日時 2017-04-15 15:35:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 2,108 ms
コンパイル使用メモリ 72,284 KB
実行使用メモリ 56,184 KB
最終ジャッジ日時 2023-08-21 07:16:52
合計ジャッジ時間 6,180 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 167 ms
55,752 KB
testcase_01 AC 170 ms
55,792 KB
testcase_02 AC 123 ms
55,800 KB
testcase_03 AC 122 ms
55,664 KB
testcase_04 AC 125 ms
55,788 KB
testcase_05 AC 128 ms
55,632 KB
testcase_06 AC 127 ms
53,996 KB
testcase_07 AC 124 ms
55,460 KB
testcase_08 AC 124 ms
56,184 KB
testcase_09 AC 127 ms
55,944 KB
testcase_10 AC 126 ms
55,712 KB
testcase_11 AC 126 ms
55,984 KB
testcase_12 AC 124 ms
55,720 KB
testcase_13 AC 125 ms
55,664 KB
testcase_14 AC 124 ms
55,968 KB
testcase_15 AC 123 ms
55,964 KB
testcase_16 AC 125 ms
55,656 KB
testcase_17 AC 125 ms
55,704 KB
testcase_18 AC 141 ms
53,980 KB
testcase_19 AC 138 ms
55,892 KB
testcase_20 AC 154 ms
56,048 KB
testcase_21 AC 169 ms
55,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int numCharacters = sc.nextInt();
        int numHoles = sc.nextInt();

        StringBuilder sb = new StringBuilder();

        while (numHoles > numCharacters) {

            sb.append("B");
            numHoles -= 2;
            numCharacters--;

        }

        while (numHoles != 0) {

            sb.insert(0, 'A');
            numHoles--;
            numCharacters--;

        }

        while (numCharacters != 0) {

            sb.append("C");
            numCharacters--;

        }

        System.out.println(sb.toString());

    }

}
0