結果

問題 No.1083 余りの余り
ユーザー kusaf_
提出日時 2024-07-18 17:32:24
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 3,104 ms
コンパイル使用メモリ 257,644 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-18 17:32:30
合計ジャッジ時間 4,530 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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 - 1); 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