結果
| 問題 | No.1083 余りの余り | 
| コンテスト | |
| ユーザー |  le_panda_noir | 
| 提出日時 | 2020-06-20 20:51:55 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 64 ms / 3,000 ms | 
| コード長 | 731 bytes | 
| コンパイル時間 | 1,117 ms | 
| コンパイル使用メモリ | 77,952 KB | 
| 最終ジャッジ日時 | 2025-01-11 08:47:08 | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 31 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
int main() {
  int N, K;
  ins(N, K);
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  all(sort, A);
  all(reverse, A);
  int ans = 0;
  if (N == 1) {
    cout << K % A[0] << endl;
    return 0;
  }
  rep(bit, 1<<(N-1)) {
    int x = K;
    rep(i, N) {
      if (bit & (1 << i)) {
        x %= A[i];
      }
    }
    ans = max(ans, x % A.back());
  }
  cout << ans << endl;
  return 0;
}
            
            
            
        