結果

問題 No.1083 余りの余り
ユーザー kusaf_
提出日時 2024-07-18 17:33:32
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 224 ms / 3,000 ms
コード長 466 bytes
コンパイル時間 3,133 ms
コンパイル使用メモリ 256,188 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-18 17:33:38
合計ジャッジ時間 5,538 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll N, K;
  cin >> N >> K;

  vector<ll> A(N);
  for(auto &i : A) { cin >> i; }
  ranges::sort(A, ranges::greater());

  ll ans = 0;
  for(ll i = 1; i < 1 << N; i++) {
    ll k = K;
    for(ll j = 0; j < N - 1; j++) {
      if(i >> j & 1) { k %= A[j]; }
    }
    k %= A.back();
    ans = max(ans, k);
  }

  cout << ans << "\n";
}
0