結果

問題 No.1083 余りの余り
ユーザー ks2mks2m
提出日時 2020-06-19 22:02:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 4,048 ms
コンパイル使用メモリ 71,068 KB
実行使用メモリ 60,544 KB
最終ジャッジ日時 2023-09-16 14:17:55
合計ジャッジ時間 10,766 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,732 KB
testcase_01 AC 124 ms
55,664 KB
testcase_02 AC 122 ms
55,992 KB
testcase_03 AC 120 ms
56,076 KB
testcase_04 WA -
testcase_05 AC 164 ms
55,972 KB
testcase_06 AC 120 ms
55,780 KB
testcase_07 AC 124 ms
56,328 KB
testcase_08 AC 123 ms
56,436 KB
testcase_09 AC 124 ms
56,144 KB
testcase_10 AC 126 ms
55,888 KB
testcase_11 WA -
testcase_12 AC 119 ms
55,344 KB
testcase_13 AC 120 ms
56,180 KB
testcase_14 AC 121 ms
55,352 KB
testcase_15 AC 118 ms
55,960 KB
testcase_16 AC 120 ms
55,472 KB
testcase_17 AC 119 ms
56,240 KB
testcase_18 WA -
testcase_19 AC 161 ms
55,980 KB
testcase_20 AC 123 ms
55,888 KB
testcase_21 AC 136 ms
55,904 KB
testcase_22 AC 121 ms
55,668 KB
testcase_23 AC 265 ms
58,564 KB
testcase_24 AC 265 ms
60,348 KB
testcase_25 AC 266 ms
60,236 KB
testcase_26 AC 269 ms
59,636 KB
testcase_27 AC 119 ms
55,352 KB
testcase_28 WA -
testcase_29 AC 119 ms
55,404 KB
testcase_30 AC 119 ms
56,048 KB
testcase_31 AC 121 ms
55,708 KB
testcase_32 AC 119 ms
55,624 KB
testcase_33 AC 265 ms
60,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int n2 = 1 << n;
		int[] dp = new int[n2];
		dp[0] = k;
		for (int i = 1; i < n2; i++) {
			for (int j = 0; j < n; j++) {
				if ((i >> j & 1) == 1) {
					int pre = i - (1 << j);
					dp[i] = Math.max(dp[i], dp[pre] % a[j]);
				}
			}
		}
		System.out.println(dp[n2 - 1]);
	}
}
0