結果

問題 No.1083 余りの余り
ユーザー ateate
提出日時 2020-06-19 23:31:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 394 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 201,556 KB
実行使用メモリ 11,664 KB
最終ジャッジ日時 2023-09-16 15:45:36
合計ジャッジ時間 7,299 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;

  auto chmax = [](auto& a,auto b){if(a<b)a=b;};
  vector dp(1<<n,0ll);
  dp[0] = k;
  for(int b=0;b<(1<<n);++b){
    for(int i=0;i<n;++i){
      chmax(dp[b|(1<<i)],dp[b]%a[i]);
    }
  }
  int ans = (1<<(n+1))-1;
  ans = dp[ans];
  cout<<(ans)<<endl;

}
0