結果

問題 No.501 穴と文字列
ユーザー samplelpmassamplelpmas
提出日時 2017-04-15 15:37:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 1,824 ms
コンパイル使用メモリ 74,604 KB
実行使用メモリ 41,700 KB
最終ジャッジ日時 2024-05-08 12:37:37
合計ジャッジ時間 5,218 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
41,700 KB
testcase_01 AC 140 ms
40,480 KB
testcase_02 AC 104 ms
40,348 KB
testcase_03 AC 104 ms
40,224 KB
testcase_04 AC 113 ms
40,816 KB
testcase_05 AC 117 ms
41,412 KB
testcase_06 AC 116 ms
41,024 KB
testcase_07 AC 113 ms
40,736 KB
testcase_08 AC 116 ms
41,360 KB
testcase_09 AC 115 ms
41,216 KB
testcase_10 AC 108 ms
40,756 KB
testcase_11 AC 116 ms
41,336 KB
testcase_12 AC 112 ms
40,844 KB
testcase_13 AC 114 ms
41,104 KB
testcase_14 AC 113 ms
40,880 KB
testcase_15 AC 104 ms
39,936 KB
testcase_16 AC 105 ms
40,148 KB
testcase_17 AC 105 ms
40,312 KB
testcase_18 AC 119 ms
41,060 KB
testcase_19 AC 112 ms
40,288 KB
testcase_20 AC 137 ms
41,572 KB
testcase_21 AC 148 ms
41,380 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