結果
問題 |
No.2324 Two Countries within UEC
|
ユーザー |
|
提出日時 | 2023-05-28 14:07:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 4,232 ms |
コンパイル使用メモリ | 250,372 KB |
最終ジャッジ日時 | 2025-02-13 10:52:12 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 WA * 11 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using ll = long long; #define MOD 1000000007 #define Mod 998244353 const int MAX = 1000000005; const long long INF = 1000000000000000005LL; using namespace std; using namespace atcoder; ll modpow(ll a, ll n, ll m) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % m; a = a * a % m; n >>= 1; } return res; } ll modinv(ll a, ll m) { return modpow(a, m-2, m); } int main() { ios::sync_with_stdio(0);cin.tie(); int N, M, P, Q; cin >> N >> M >> P >> Q; while (Q--) { int x, f; cin >> x >> f; int a = modinv(x, P) * f % P; if (M < a) { cout << 0 << endl; } else { cout << (M - a)/P + 1 - (a == 0) << endl; } } }