結果

問題 No.1083 余りの余り
ユーザー 0w1
提出日時 2020-11-16 23:10:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 47 ms / 3,000 ms
コード長 458 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 197,224 KB
最終ジャッジ日時 2025-01-16 01:14:28
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  ios::sync_with_stdio(false);

  int N, K; {
    cin >> N >> K;
  }

  vector<int> A(N); {
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end());
  }

  int res = 0; {
    for (int s = 0; s < 1 << N; ++s) if (s & 1) {
      int k = K;
      for (int i = N - 1; ~i; --i) if (s >> i & 1) {
        k %= A[i];
      }
      res = max(res, k);
    }
  }

  cout << res << endl;
}

0