結果

問題 No.2324 Two Countries within UEC
ユーザー primenumber11primenumber11
提出日時 2023-05-28 15:26:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,521 bytes
コンパイル時間 4,309 ms
コンパイル使用メモリ 259,132 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-08-27 12:09:31
合計ジャッジ時間 11,610 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 260 ms
4,380 KB
testcase_01 AC 277 ms
4,380 KB
testcase_02 AC 49 ms
4,380 KB
testcase_03 AC 200 ms
4,380 KB
testcase_04 AC 228 ms
4,380 KB
testcase_05 AC 52 ms
4,376 KB
testcase_06 AC 92 ms
4,384 KB
testcase_07 AC 42 ms
4,380 KB
testcase_08 AC 200 ms
4,380 KB
testcase_09 AC 204 ms
4,380 KB
testcase_10 AC 272 ms
4,380 KB
testcase_11 AC 268 ms
4,384 KB
testcase_12 AC 82 ms
4,380 KB
testcase_13 AC 80 ms
4,376 KB
testcase_14 AC 49 ms
4,384 KB
testcase_15 AC 42 ms
4,380 KB
testcase_16 AC 183 ms
4,376 KB
testcase_17 AC 117 ms
4,376 KB
testcase_18 AC 53 ms
4,380 KB
testcase_19 AC 270 ms
4,380 KB
testcase_20 AC 35 ms
4,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 271 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 2 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
/*
hi, I'm rintaro.
AC is right
AC count is my life
But don't solve too many easy plobems!
*/
#define g(n,m) get<n>(m)
#define fof(i,o,n) for (ll i = o; i < (ll)n; i++)
#define fof_(dontuseit,a) for(auto &dontuseit : a)
#define vcin(a) fof_(i,a) cin>>i
#define all(o) o.begin(),o.end()
#define double long double
#define pii pair<ll,ll>
#define vec vector
#define vi vec<ll>
#define vs vec<string>
#define vc vec<char>
#define vvi vec<vi>
#define vpii vec<pii>
#define igpqueue priority_queue<ll,vi,greater<ll>>
#define re return
#define r0 re 0
#define ln(n) cout << n << endl
#define fix(n) << fixed << setprecision(n)
#define out_(n) << n << " "
#define Out cout
#define out(n) << n
#define End << endl
#define imap map<ll,ll>
#define smap map<string,ll>
#define gmap map<ll,vector<ll>>
#define m9 998244353
#define m7 1000000007
#define lny ln("Yes")
#define lnn ln("No")
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1LL) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
int main() {
  ll N, M, P, Q;
  cin >> N >> M >> P >> Q;
  fof(i,0,Q) {
    ll a,f;
    cin>>a>>f;
    if(M%P>=((f%P)*(modinv(a,P)%P)%P+((f%P)*(modinv(a,P)%P)%P==0?P:0))) ln(M/P+1);
    else ln(M/P);
  }
}
0