結果
問題 | No.1663 Maximum Remainder |
ユーザー |
|
提出日時 | 2021-09-04 15:02:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 1,626 bytes |
コンパイル時間 | 1,544 ms |
コンパイル使用メモリ | 169,816 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-18 01:39:36 |
合計ジャッジ時間 | 2,240 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h>#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)#define REP(i,n) FOR(i,0,n)#define ALL(v) (v).begin(),(v).end()#define SUM(v) accumulate(ALL(v),0ll)#define CL(v) cout<<v<<endlusing ll = long long;const ll INF=10101010;const ll mod=1e9+7;using namespace std;using P = pair<int,int>;ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}class UnionFind {public:vector <ll> par;vector <ll> siz;// ConstructorUnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {for (ll i = 0; i < sz_; ++i) par[i] = i;}void init(ll sz_) {par.resize(sz_);siz.assign(sz_, 1LL);for (ll i = 0; i < sz_; ++i) par[i] = i;}// Member Function// Findll root(ll x) { // 根の検索while (par[x] != x) {x = par[x] = par[par[x]];}return x;}// Union(Unite, Merge)bool merge(ll x, ll y) {x = root(x);y = root(y);if (x == y) return false;if (siz[x] < siz[y]) swap(x, y);siz[x] += siz[y];par[y] = x;return true;}bool issame(ll x, ll y) {return root(x) == root(y);}ll size(ll x) {return siz[root(x)];}};ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}//--------------------------------//modint main(){int a,b,c,d,m;cin>>a>>b>>c>>d>>m;int ans=-1;for(int x=a;x<=b;x++){for(int y=c;y<=d;y++){ans=max(ans,(x+y)%m);}}cout<<ans<<endl;return 0;}