結果

問題 No.1083 余りの余り
ユーザー keijakkeijak
提出日時 2020-06-19 21:43:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,221 bytes
コンパイル時間 2,058 ms
コンパイル使用メモリ 201,880 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-16 13:46:37
合計ジャッジ時間 3,278 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define debug(...)
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

const i64 INF = 1LL << 40;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  vector<i64> A(N);
  i64 mx = INF;
  for (auto& x : A) {
    cin >> x;
    mx = min(mx, x);
  }

  i64 ans = 0;
  auto solve = [&](auto rec, int i, i64 val) -> void {
    if (i == N) return;
    if (val < mx) {
      if (ans < val) ans = val;
      return;
    }

    rec(rec, i + 1, val);
    rec(rec, i + 1, val % A[i]);
  };
  solve(solve, 0, K);
  cout << ans << endl;
}
0