結果
問題 | No.1083 余りの余り |
ユーザー |
![]() |
提出日時 | 2020-12-04 11:22:11 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 839 bytes |
コンパイル時間 | 3,183 ms |
コンパイル使用メモリ | 74,172 KB |
実行使用メモリ | 61,476 KB |
最終ジャッジ日時 | 2024-09-14 21:39:34 |
合計ジャッジ時間 | 8,053 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 TLE * 1 -- * 28 |
ソースコード
import java.util.*;public class Main {static int n;static int[] values;static int max = 0;public static void main(String[] args) {Scanner sc = new Scanner(System.in);n = sc.nextInt();int k = sc.nextInt();values = new int[n];for (int i = 0; i < n; i++) {values[i] = sc.nextInt();}search(k, 0, new boolean[n]);System.out.println(max);}static void search(int value, int idx, boolean[] used) {if (idx == n) {max = Math.max(max, value);return;}for (int i = 0; i < n; i++) {if (used[i]) {continue;}used[i] = true;search(value % values[i], idx + 1, used);used[i] = false;}}}