結果
| 問題 |
No.1083 余りの余り
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-19 21:30:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 3,000 ms |
| コード長 | 517 bytes |
| コンパイル時間 | 1,552 ms |
| コンパイル使用メモリ | 171,128 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-03 13:56:58 |
| 合計ジャッジ時間 | 2,553 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int n;
int a[30];
int dfs(int i, int k){
if(i == n-1) return k%a[i];
return max(dfs(i+1, k), dfs(i+1, k%a[i]));
}
signed main(){
int k;
cin >> n >> k;
for(int i = 0;i < n;i++) cin >> a[i];
sort(a, a+n, greater<int>());
cout << dfs(0, k) << endl;
return 0;
}