結果

問題 No.1083 余りの余り
ユーザー snrnsidy
提出日時 2021-10-05 01:32:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 461 bytes
コンパイル時間 1,862 ms
コンパイル使用メモリ 194,312 KB
最終ジャッジ日時 2025-01-24 20:34:13
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int dp[1<<20];

int main(void) 
{
	cin.tie(0);
	ios::sync_with_stdio(false);

  int n,k,t;
  vector <int> a;

  cin >> n >> k;

  for(int i=0;i<n;i++)
  {
    cin >> t;
    a.push_back(t);
  }

  dp[0] = k;

  for(int i=0;i<(1<<n);i++)
  {
    for(int j=0;j<n;j++)
    {
      if((i&(1<<j))) continue;
      dp[i+(1<<j)] = max(dp[i + (1<<j)],dp[i]%a[j]);
    }
  }

  cout << dp[(1<<n)-1] << '\n';
  
	return 0;
}
0