結果

問題 No.2324 Two Countries within UEC
ユーザー 0214sh70214sh7
提出日時 2023-05-28 13:53:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,191 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 198,756 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-27 08:37:10
合計ジャッジ時間 9,171 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 256 ms
4,376 KB
testcase_01 AC 270 ms
4,380 KB
testcase_02 AC 49 ms
4,376 KB
testcase_03 AC 203 ms
4,376 KB
testcase_04 AC 231 ms
4,376 KB
testcase_05 AC 52 ms
4,376 KB
testcase_06 AC 92 ms
4,376 KB
testcase_07 AC 42 ms
4,376 KB
testcase_08 AC 197 ms
4,376 KB
testcase_09 AC 203 ms
4,380 KB
testcase_10 AC 269 ms
4,376 KB
testcase_11 AC 262 ms
4,376 KB
testcase_12 AC 82 ms
4,380 KB
testcase_13 AC 81 ms
4,380 KB
testcase_14 AC 49 ms
4,376 KB
testcase_15 AC 42 ms
4,376 KB
testcase_16 AC 182 ms
4,384 KB
testcase_17 AC 116 ms
4,376 KB
testcase_18 AC 52 ms
4,376 KB
testcase_19 AC 271 ms
4,380 KB
testcase_20 AC 35 ms
4,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 267 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,384 KB
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define ALL(v) (v).begin(), (v).end()
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug true
#define debug2 false

long long inverse(long long b,long long mod){
    /*
    Copyright (c) 2021 0214sh7
    https://github.com/0214sh7/library/
    */
    long long r=1,e=mod-2;
    while(e){
        if(e&1){
            r=(r*b)%mod;
        }
        b=(b*b)%mod;
        e >>=1;
    }
    return r;
}

int main(void){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);

    ll N,M,P,Q;
    cin >> N >> M >> P >> Q;
    REP(i,Q){

        ll x,f;
        cin >> x >> f;

        ll y = (f*inverse(x%P,P))%P;
        //cout << y << endl;
        ll Ans = (M+P-y)/P;
        if(y ==0)Ans--;
        cout << Ans << endl;

    }

    return 0;
}
0