結果

問題 No.2324 Two Countries within UEC
ユーザー gyozasukisukigyozasukisuki
提出日時 2023-05-28 14:25:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,105 bytes
コンパイル時間 1,996 ms
コンパイル使用メモリ 197,660 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 09:44:52
合計ジャッジ時間 8,989 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 231 ms
4,380 KB
testcase_01 AC 243 ms
4,380 KB
testcase_02 AC 45 ms
4,376 KB
testcase_03 AC 185 ms
4,376 KB
testcase_04 AC 210 ms
4,376 KB
testcase_05 AC 47 ms
4,380 KB
testcase_06 AC 83 ms
4,376 KB
testcase_07 AC 38 ms
4,376 KB
testcase_08 AC 180 ms
4,380 KB
testcase_09 AC 184 ms
4,376 KB
testcase_10 AC 249 ms
4,380 KB
testcase_11 AC 241 ms
4,384 KB
testcase_12 AC 74 ms
4,380 KB
testcase_13 AC 73 ms
4,380 KB
testcase_14 AC 44 ms
4,380 KB
testcase_15 AC 39 ms
4,380 KB
testcase_16 AC 163 ms
4,376 KB
testcase_17 AC 105 ms
4,376 KB
testcase_18 AC 48 ms
4,380 KB
testcase_19 AC 248 ms
4,376 KB
testcase_20 AC 33 ms
4,380 KB
testcase_21 WA -
testcase_22 AC 208 ms
4,376 KB
testcase_23 AC 65 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 245 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,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,384 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
const int INF = 1e9;
using ll = long long;
using inv = vector<int>;
using stv = vector<string>;
using pint = pair<int,int>;
#define FOR(i,l,r) for(int i=(l); i<(r); i++)
#define rep(i,r) for(int i=0; i<(r); i++)
#define repl(i,r) for(long long i=0; i<(r); i++)
#define FORl(i,l,r) for(long long i=(l); i<(r); i++)
#define INFL ((1LL<<62)-(1LL<<31))
#define pb(x) push_back(x)
#define CIN(x) cin >> x

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}


int main(){
  ll N,M,P,Q;
  cin >> N >> M >> P >> Q;
  rep(q,Q){
    
    ll x,f;
    cin >> x >> f;
    if(x % P == 0){
      cout << 0 << endl;
      continue;
    }

    ll res = M/P;

    ll p = (f*modinv(x,P))%P;

    if(p >= 1 &&M%P >= p) res++;
    //cout << "M%P" << M%P << " " << "p:" <<(f*modinv(x,P))%P << endl;
    cout << res << endl;

  }
  
}
0