結果

問題 No.501 穴と文字列
ユーザー tentententen
提出日時 2022-08-02 10:19:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,472 bytes
コンパイル時間 4,724 ms
コンパイル使用メモリ 74,452 KB
実行使用メモリ 49,992 KB
最終ジャッジ日時 2023-09-30 09:07:18
合計ジャッジ時間 6,980 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
49,336 KB
testcase_01 AC 47 ms
49,236 KB
testcase_02 AC 46 ms
49,240 KB
testcase_03 AC 44 ms
49,276 KB
testcase_04 AC 45 ms
49,288 KB
testcase_05 AC 45 ms
49,388 KB
testcase_06 AC 44 ms
49,992 KB
testcase_07 AC 45 ms
49,356 KB
testcase_08 AC 44 ms
49,360 KB
testcase_09 AC 44 ms
49,668 KB
testcase_10 AC 45 ms
49,284 KB
testcase_11 AC 45 ms
49,400 KB
testcase_12 AC 45 ms
49,152 KB
testcase_13 AC 44 ms
49,760 KB
testcase_14 AC 45 ms
49,296 KB
testcase_15 AC 45 ms
49,244 KB
testcase_16 AC 44 ms
49,220 KB
testcase_17 AC 44 ms
49,264 KB
testcase_18 AC 46 ms
49,348 KB
testcase_19 AC 47 ms
49,528 KB
testcase_20 AC 47 ms
49,192 KB
testcase_21 AC 48 ms
49,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int d = sc.nextInt();
        if (d > n) {
            int b = d - n;
            char[] bstr = new char[b];
            Arrays.fill(bstr, 'B');
            char[] astr = new char[n - b];
            Arrays.fill(astr, 'A');
            System.out.print(astr);
            System.out.println(bstr);
        } else {
            int c = n - d;
            char[] cstr = new char[c];
            Arrays.fill(cstr, 'C');
            char[] astr = new char[n - c];
            Arrays.fill(astr, 'A');
            System.out.print(astr);
            System.out.println(cstr);
        }
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0