結果

問題 No.3498 Modulo Equation
コンテスト
ユーザー nagotch
提出日時 2026-04-18 13:54:09
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,438 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,082 ms
コンパイル使用メモリ 332,488 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-18 13:54:13
合計ジャッジ時間 3,340 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
using vl = vc<ll>;
using vs = vc<string>;
using vb = vc<bool>;
using vvl = vv<ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rrep(i,n) for(ll i=(n)-1;0<=i;i--)
#define nfor(i,s,n) for(ll i=s;i<n;i++)
#define fore(i, x) for(auto i : x)
template<class T>ostream& operator<<(ostream& o, vc<T>& v) {rep(j,size(v))o<<v[j]<<" ";cout<<endl;return o;}
template<class T>istream& operator>>(istream& i, vc<T>& v) {rep(j,size(v))i>>v[j];return i;}
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define pob pop_back
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define YN {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define ANS cout<<ans<<endl;
ll power(ll a,ll b,ll m){ll r=1,p=a;rep(i,30){if(1&b>>i){r*=p%m;r%=m;}p=(p*p)%m;}r%=m;return r;}
ll power(ll a,ll b){ll r=1,p=a;rep(i,30){if(1&b>>i)r*=p;p*=p;}return r;}
bool out_grid(ll i,ll j,ll h,ll w){return i<0||w<=i||j<0||h<=j;}
ll INF = 2e18;vl di={1,0,-1,0},dj={0,-1,0,1};
ll MOD = 1000000007;
// ll MOD = 998244353;

int main() {
    ll a, b;
    cin >> a >> b;
    rep(i, 2000000) {
        if (i<=0) continue;
        if (i % a == b % i) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}
0