結果

問題 No.1819 Mirrored 2
ユーザー hiikunZ
提出日時 2022-05-14 18:22:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,381 bytes
コンパイル時間 1,993 ms
コンパイル使用メモリ 196,180 KB
最終ジャッジ日時 2025-01-29 08:08:41
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
constexpr ll MAX = 2000000000000000000;
constexpr ld PI = 3.14159265358979;
constexpr ll MOD = 0;//2024948111;
ld dotorad(ld K){return PI * K / 180.0;}
ld radtodo(ld K){return K * 180.0 / PI;}
mt19937 mt;
void randinit(){srand((unsigned)time(NULL));mt = mt19937(rand());}
int main(){
    ll P,Q,X,Y;
    cin >> P >> Q >> X >> Y;
    while(Y % 10 == 0){
        Y += Q;
    }
    string y = to_string(Y);
    string S = y;
    reverse(S.begin(),S.end());
    ll f = stol(S) % P;
    while(1){
        if(f == X){
            cout << S << endl;
            {
                ll p = 0;
                for(ll i = 0;i < (ll)S.size();i++){
                    p = (p * 10) % P;
                    p += S[i] - '0';
                    p %= P;
                }
                if(p != X % P) cout << "Error" << endl;
            }
            {
                ll p = 0;
                for(ll i = (ll)S.size() - 1;i >= 0;i--){
                    p = (p * 10) % Q;
                    p += S[i] - '0';
                    p %= Q;
                }
                if(p != Y % Q) cout << "Error" << endl;
            }
            return 0;
        }
        S += "0";
        f = (f * 10) % P;
    }
}
0