結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 277 ms
45,484 KB
testcase_01 AC 263 ms
45,464 KB
testcase_02 AC 101 ms
40,296 KB
testcase_03 AC 114 ms
41,124 KB
testcase_04 AC 102 ms
40,172 KB
testcase_05 AC 115 ms
41,528 KB
testcase_06 AC 114 ms
41,384 KB
testcase_07 AC 111 ms
41,084 KB
testcase_08 AC 114 ms
41,272 KB
testcase_09 AC 104 ms
40,260 KB
testcase_10 AC 103 ms
40,252 KB
testcase_11 AC 100 ms
39,940 KB
testcase_12 AC 108 ms
40,836 KB
testcase_13 AC 111 ms
41,148 KB
testcase_14 AC 112 ms
41,528 KB
testcase_15 AC 111 ms
41,092 KB
testcase_16 AC 118 ms
41,380 KB
testcase_17 AC 119 ms
41,212 KB
testcase_18 AC 315 ms
45,752 KB
testcase_19 AC 299 ms
44,988 KB
testcase_20 AC 319 ms
45,896 KB
testcase_21 AC 325 ms
45,584 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