結果

問題 No.1083 余りの余り
ユーザー iqueue02
提出日時 2020-06-20 10:37:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 70 ms / 3,000 ms
コード長 647 bytes
コンパイル時間 2,835 ms
コンパイル使用メモリ 196,492 KB
最終ジャッジ日時 2025-01-11 08:33:44
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr int mod =  1e9 + 7;
constexpr int INF = 1e9;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(), a.end(), greater<int>());
  int res = 0;
  for (int bit = 0; bit < (1 << (n - 1)); bit++) {
    int tmp = k;
    for (int i = 0; i < n - 1; i++) { 
      if (bit & (1 << i)) tmp %= a[i];
    }

    res = max(res, tmp % a[n - 1]);
  }
  cout << res << endl;
  return 0;
} 
0