結果

問題 No.2558 中国剰余定理
ユーザー 時雨煮 / Sigreni
提出日時 2023-12-02 23:53:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 191,740 KB
最終ジャッジ日時 2025-02-18 06:24:33
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); i++)
using namespace std;

int main(){
    int A, B, a, b;
    cin >> A >> B >> a >> b;
    int cnt = 0;
    while(true){
        if((A*cnt + (a-b)) % B == 0) {
            cout << A*cnt + a << endl;
            return 0;
        }
        cnt++;
    }

    

    return 0;
}
0