結果

問題 No.1083 余りの余り
ユーザー imoni_kawaiiimoni_kawaii
提出日時 2020-06-20 17:46:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 414 ms / 3,000 ms
コード長 1,083 bytes
コンパイル時間 2,591 ms
コンパイル使用メモリ 204,496 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 17:41:20
合計ジャッジ時間 6,260 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,356 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 94 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 186 ms
4,380 KB
testcase_19 AC 92 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 12 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 378 ms
4,376 KB
testcase_24 AC 384 ms
4,380 KB
testcase_25 AC 386 ms
4,376 KB
testcase_26 AC 389 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 344 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 414 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0