結果
| 問題 |
No.1083 余りの余り
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-19 21:59:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 895 bytes |
| コンパイル時間 | 2,481 ms |
| コンパイル使用メモリ | 199,956 KB |
| 最終ジャッジ日時 | 2025-01-11 06:15:46 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 TLE * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b)
{
if(a < b)
{
a = b;
return true;
}
return false;
}
void dfs(int K, vector<int> &A, vector<bool> &is_used, int &ans)
{
if(K < A[0])
{
chmax(ans, K);
return;
}
for(int i=0; i<is_used.size(); i++)
{
if(is_used[i]) continue;
is_used[i] = true;
dfs(K%A[i], A, is_used, ans);
is_used[i] = false;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int N, K;
cin >> N >> K;
vector<int> A(N);
for(int i=0; i<N; i++) cin >> A.at(i);
sort(A.begin(), A.end());
A.erase(unique(A.begin(), A.end()), A.end());
vector<bool> is_used(A.size(), false);
int ans = 0;
dfs(K, A, is_used, ans);
cout << ans << endl;
return 0;
}