結果

問題 No.501 穴と文字列
ユーザー takeya_okinotakeya_okino
提出日時 2017-09-30 20:43:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 2,236 ms
コンパイル使用メモリ 76,468 KB
実行使用メモリ 45,472 KB
最終ジャッジ日時 2024-04-27 16:59:32
合計ジャッジ時間 6,606 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 254 ms
44,904 KB
testcase_01 AC 256 ms
44,928 KB
testcase_02 AC 114 ms
40,956 KB
testcase_03 AC 98 ms
40,104 KB
testcase_04 AC 104 ms
40,180 KB
testcase_05 AC 100 ms
40,576 KB
testcase_06 AC 108 ms
41,444 KB
testcase_07 AC 115 ms
41,376 KB
testcase_08 AC 120 ms
41,004 KB
testcase_09 AC 117 ms
41,092 KB
testcase_10 AC 115 ms
41,344 KB
testcase_11 AC 101 ms
39,708 KB
testcase_12 AC 115 ms
41,052 KB
testcase_13 AC 111 ms
40,224 KB
testcase_14 AC 101 ms
40,224 KB
testcase_15 AC 115 ms
41,480 KB
testcase_16 AC 107 ms
40,204 KB
testcase_17 AC 101 ms
40,296 KB
testcase_18 AC 301 ms
45,380 KB
testcase_19 AC 304 ms
45,356 KB
testcase_20 AC 295 ms
44,696 KB
testcase_21 AC 301 ms
45,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    String ans = "";
    if(d <= n) {
      for(int i = 0; i < d; i++) {
        ans += "A";
      }
      for(int i = 0; i < (n - d); i++) {
        ans += "C";
      }
    } else if(d < (2 * n)) {
      for(int i = 0; i < (2 * n - d); i++) {
        ans += "A";
      }
      for(int i = 0; i < (d - n); i++) {
        ans += "B";
      }
    } else {
      for(int i = 0; i < n; i++) {
        ans += "B";
      }
    }
    System.out.println(ans);
  }
}
0