結果
問題 |
No.1083 余りの余り
|
ユーザー |
|
提出日時 | 2020-08-02 16:17:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 3,000 ms |
コード長 | 1,599 bytes |
コンパイル時間 | 1,434 ms |
コンパイル使用メモリ | 103,428 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 16:45:53 |
合計ジャッジ時間 | 2,450 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <vector> using namespace std; using ll = long long; #define fst first #define snd second /* clang-format off */ template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; }; template <class T> struct _vec<T, 0> { using type = T; }; template <class T, size_t D> using vec = typename _vec<T, D>::type; template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); } template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); } template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; } template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; } /* clang-format on */ int main() { #ifdef DEBUG ifstream ifs("in.txt"); cin.rdbuf(ifs.rdbuf()); #endif int N, K; while (cin >> N >> K) { vector<int> A(N); for (int &x : A) cin >> x; sort(A.rbegin(), A.rend()); int res = 0; auto dfs = [&](auto dfs, int i, int value, int unused) { if (i >= N) { if (value < unused) chmax(res, value); return; } dfs(dfs, i + 1, value, A[i]); dfs(dfs, i + 1, value % A[i], unused); }; dfs(dfs, 0, K, 1e9 + 10); cout << res << endl; } return 0; }