結果

問題 No.2117 中国剰余定理入門
ユーザー O--O
提出日時 2022-11-04 21:25:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 662 bytes
コンパイル時間 1,481 ms
コンパイル使用メモリ 165,480 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-18 19:08:27
合計ジャッジ時間 2,061 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pb emplace_back
#define F first
#define S second
const int mod = 1e9 + 7;
const int MAXX = 1e5 + 5;

int a , b , c , d;

signed main()
{
    _FastIO;
    cin >> b >> a >> d >> c;
    if(a < 0)
        a = b + a;
    if(c < 0)
        c = d + c;
    for(int i = 0; i < 1000005; i++){
        if((i % b == a) && (i % d == c)){
            cout << i << endl;
            return 0;
        }
    }
    cout << "NaN" << endl;
    return 0;
}
0