結果

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

ソースコード

diff #

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

signed main(){

  int64_t n,k;
  cin>>n>>k;
  vector<int64_t> a(n);
  for(auto& ai:a)cin>>ai;
  sort(rbegin(a),rend(a));

  auto chmax = [](auto& a,auto b){if(a<b)a=b;};

  int64_t ans = 0;
  for(int b=0;b<(1<<n);++b){
    int64_t x = k;
    for(int i=0;i<n;++i)if(b>>i&1){
      x %= a[i];
    }
    x %= a.back();
    chmax(ans,x);
  }
  cout<<(ans)<<endl;

}
0