結果

問題 No.1083 余りの余り
ユーザー keijak
提出日時 2020-06-19 21:35:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,052 bytes
コンパイル時間 4,033 ms
コンパイル使用メモリ 193,948 KB
最終ジャッジ日時 2025-01-11 05:51:58
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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;
  REP(i, N) {
    i64 y = (K % A[i]) % mx;
    ans = max(ans, y);
  }
  cout << ans << endl;
}
0