結果
問題 | No.1083 余りの余り |
ユーザー |
![]() |
提出日時 | 2023-03-15 00:37:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 3,000 ms |
コード長 | 1,205 bytes |
コンパイル時間 | 1,788 ms |
コンパイル使用メモリ | 177,208 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-18 08:32:12 |
合計ジャッジ時間 | 2,872 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h>using std::cin;using std::cout;using std::endl;using ll = long long;std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());template <class T>inline bool chmax(T &a, T b) {if (a < b) {a = b;return 1;}return 0;}template <class T>inline bool chmin(T &a, T b) {if (a > b) {a = b;return 1;}return 0;}const int inf = (int)1e9 + 7;const long long INF = 1LL << 60;void solve() {int n, K;cin >> n >> K;std::vector<int> a(n);for (int i = 0; i < n; ++i) {cin >> a[i];}std::sort(a.rbegin(), a.rend());a.erase(std::unique(a.begin(), a.end()), a.end());n = (int)a.size();ll res = 0;auto dfs = [&](auto &&self, int cur, ll val) -> void {if (cur == n - 1) {chmax(res, val % a[cur]);return;}self(self, cur + 1, val);self(self, cur + 1, val % a[cur]);};dfs(dfs, 0, K);cout << res << "\n";}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);int I_love_KKT89 = 1;// cin >> I_love_KKT89;for (int Case = 1; Case <= I_love_KKT89; ++Case) {// cout << "Case #" << Case << ": ";solve();}return 0;}