結果
問題 | No.1663 Maximum Remainder |
ユーザー |
|
提出日時 | 2021-09-03 21:21:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 1,915 bytes |
コンパイル時間 | 1,850 ms |
コンパイル使用メモリ | 167,508 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-15 09:32:24 |
合計ジャッジ時間 | 2,106 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
#include<bits/stdc++.h>#include<unordered_map>#define for_int(i,a,b) for(int i=(a);i<=(b);++i)#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)#define Ios std::ios::sync_with_stdio(false),std::cin.tie(0)#define ull unsigned long long#define ll long long#define db double#define PII std::pair<int,int>#define PLI std::pair<long long , int>template<class T> void chkmax(T& a, T b) { a > b ? (a = a) : (a = b); }template<class T> void chkmin(T& a, T b) { a > b ? (a = b) : (a = a); }template<class T> T min(T a, T b) { return a > b ? b : a; }template<class T> T max(T a, T b) { return a < b ? b : a; }template<class T> T abs(T a) { return a < 0 ? -a : a; }//using namespace std;/*1.注意边界情况2.优先考虑时间复杂度!!! 3.求最大值时,答案应至多初始化为INT_MIN;求最小值时,答案应至少初始化为INT_MAX4.遇事不决先暴力5.代码要写简洁6.计数题要开long long*///快速IOtemplate<class T>inline bool rd(T& ret) {char c; int sgn;if (c = getchar(), c == EOF) return 0;while (c != '-' && (c < '0' || c > '9')) c = getchar();sgn = (c == '-') ? -1 : 1;ret = (c == '-') ? 0 : (c - '0');while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');ret *= sgn;return true;}template<class T>inline void print(T x) {if (x > 9) print(x / 10);putchar(x % 10 + '0');return;}using std::vector;using std::queue;using std::string;using std::map;using std::unordered_map;using std::priority_queue;using std::cout;using std::cin;int a, b, c, d, m;int main() {rd(a); rd(b); rd(c); rd(d); rd(m);int res = 0;for (int i = a; i <= b; ++i)for (int j = c; j <= d; ++j)chkmax(res, (i + j) % m);print(res); puts("");return 0;}