結果

問題 No.1083 余りの余り
ユーザー udon1206udon1206
提出日時 2023-03-15 00:37:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 3,000 ms
コード長 1,205 bytes
コンパイル時間 1,773 ms
コンパイル使用メモリ 176,324 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 12:10:28
合計ジャッジ時間 3,355 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 5 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 8 ms
4,348 KB
testcase_19 AC 5 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 14 ms
4,348 KB
testcase_24 AC 14 ms
4,348 KB
testcase_25 AC 14 ms
4,348 KB
testcase_26 AC 14 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 14 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0