結果

問題 No.1663 Maximum Remainder
ユーザー packer_jp
提出日時 2021-09-03 21:21:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 2,321 bytes
コンパイル時間 2,007 ms
コンパイル使用メモリ 192,328 KB
最終ジャッジ日時 2025-01-24 04:32:29
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
ull bit(int n) { return 1ull << n; }
ll sign(ll a) { return (a > 0) - (a < 0); }
ll fdiv(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); }
ll cdiv(ll a, ll b) { return -fdiv(-a, b); }
template <typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
template <typename T> T sq(const T &a) { return a * a; }
template <typename T, typename U> bool chmax(T &a, const U &b) { return ((a < b) ? (a = b, true) : (false)); }
template <typename T, typename U> bool chmin(T &a, const U &b) { return ((a > b) ? (a = b, true) : (false)); }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &a) {
os << "(";
for (auto itr = a.begin(); itr != a.end(); itr++) { os << *itr << (next(itr) != a.end() ? ", " : ""); }
os << ")";
return os;
}
#ifdef ONLINE_JUDGE
#define dump(...) (void(0))
#else
void debug() { cerr << endl; }
template <typename Head, typename... Tail> void debug(Head &&head, Tail &&... tail) {
cerr << head;
if (sizeof...(Tail)) cerr << ", ";
debug(tail...);
}
#define dump(...) cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ", debug(__VA_ARGS__)
#endif
struct rep {
struct itr {
int v;
itr(int v) : v(v) {}
void operator++() { ++v; }
int operator*() const { return v; }
bool operator!=(const itr &i) const { return v != i.v; }
};
int l, r;
rep(int r) : l(min(0, r)), r(r) {}
rep(int l, int r) : l(min(l, r)), r(r) {}
itr begin() const { return l; };
itr end() const { return r; };
};
struct per {
struct itr {
int v;
itr(int v) : v(v) {}
void operator++() { --v; }
int operator*() const { return v; }
bool operator!=(const itr &i) const { return v != i.v; }
};
int l, r;
per(int r) : l(min(0, r)), r(r) {}
per(int l, int r) : l(min(l, r)), r(r) {}
itr begin() const { return r - 1; };
itr end() const { return l - 1; };
};
int main() {
ll a, b, c, d, m;
cin >> a >> b >> c >> d >> m;
ll ans = 0;
for (ll x : rep(a, b + 1)) {
for (ll y : rep(c, d + 1)) { chmax(ans, (x + y) % m); }
}
cout << ans << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0