結果

問題 No.1083 余りの余り
ユーザー simansiman
提出日時 2020-12-20 19:57:41
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 3,276 ms
コンパイル使用メモリ 131,460 KB
実行使用メモリ 7,572 KB
最終ジャッジ日時 2023-10-21 11:00:13
合計ジャッジ時間 6,048 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;
const int MAX_N = 20;
int dp[1 << MAX_N];

int main() {
  int N, K;
  cin >> N >> K;
  memset(dp, -1, sizeof(dp));
  dp[0] = K;

  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  for (int i = 0; i < N; ++i) {
    for (int mask = 0; mask < (1 << N); ++mask) {
      if (__builtin_popcount(mask) != i) continue;

      for (int j = 0; j < N; ++j) {
        if (mask >> j & 1) continue;
        int nmask = mask | (1 << j);

        dp[nmask] = max(dp[nmask], dp[mask] % A[j]);
      }
    }
  }

  cout << dp[(1 << N) - 1] << endl;

  return 0;
}
0