結果

問題 No.501 穴と文字列
ユーザー ぴろずぴろず
提出日時 2017-04-07 22:55:29
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 496 bytes
コンパイル時間 2,255 ms
コンパイル使用メモリ 72,548 KB
実行使用メモリ 56,104 KB
最終ジャッジ日時 2023-09-23 02:26:40
合計ジャッジ時間 6,110 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 128 ms
55,760 KB
testcase_02 AC 121 ms
55,824 KB
testcase_03 AC 122 ms
55,596 KB
testcase_04 AC 121 ms
55,448 KB
testcase_05 WA -
testcase_06 AC 122 ms
55,832 KB
testcase_07 AC 122 ms
55,708 KB
testcase_08 AC 121 ms
56,104 KB
testcase_09 AC 122 ms
55,720 KB
testcase_10 AC 121 ms
55,608 KB
testcase_11 AC 121 ms
55,716 KB
testcase_12 AC 122 ms
55,808 KB
testcase_13 AC 123 ms
55,768 KB
testcase_14 WA -
testcase_15 AC 120 ms
55,608 KB
testcase_16 AC 124 ms
55,872 KB
testcase_17 AC 123 ms
56,040 KB
testcase_18 WA -
testcase_19 AC 131 ms
56,036 KB
testcase_20 WA -
testcase_21 AC 130 ms
55,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no501;

import java.util.Scanner;

public class Main {
	static int[] h = {1,2,0};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		char[] c = new char[n];
		for(int i=0;i<n;i++) {
			for(int j=0;j<=2;j++) {
				if ((i == n - 1 && d == h[j]) || (i < n - 1 && (n-1-i) * 2 >= d - h[j])) {
					c[i] = (char) ('A' + j);
					d -= h[j];
					break;
				}
			}
		}
		System.out.println(String.valueOf(c));
	}

}
0