結果
| 問題 | No.1083 余りの余り | 
| コンテスト | |
| ユーザー |  imoni_kawaii | 
| 提出日時 | 2020-06-20 17:46:25 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 435 ms / 3,000 ms | 
| コード長 | 1,083 bytes | 
| コンパイル時間 | 2,046 ms | 
| コンパイル使用メモリ | 200,252 KB | 
| 最終ジャッジ日時 | 2025-01-11 08:46:11 | 
| ジャッジサーバーID (参考情報) | judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 31 | 
ソースコード
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using ll = long long; using ld = long double; using pll = pair<ll, ll>;
const int INF = 1<<30; const ll LINF = 1LL<<60; const ld PI = 3.1415926535897932;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll mn = LINF;
  rep(i, n) chmin(mn, a[i]);
  ll ans = 0;
  rep(S, 1<<n) {
    vector<ll> b;
    rep(i, n) {
      if(S>>i&1) b.push_back(a[i]);
    }
    sort(b.begin(), b.end(), greater<ll>());
    if(b.size() == 0 || b[b.size()-1] > mn) continue;
    ll res = k;
    rep(i, b.size()) res %= b[i];
    chmax(ans, res);
  }
  cout << ans << '\n';
  return 0;
}
            
            
            
        