結果
| 問題 |
No.2324 Two Countries within UEC
|
| コンテスト | |
| ユーザー |
kobaryo222
|
| 提出日時 | 2023-05-28 14:05:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,110 bytes |
| コンパイル時間 | 2,102 ms |
| コンパイル使用メモリ | 195,564 KB |
| 最終ジャッジ日時 | 2025-02-13 10:46:39 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 WA * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF (1LL << 60)
#define all(v) (v).begin(), (v).end()
template <class T>
void chmin(T &a, T b) {
if (a > b) a = b;
}
template <class T>
void chmax(T &a, T b) {
if (a < b) a = b;
}
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
// a^-1
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;
vector<ll> x(Q), f(Q);
rep(i, Q) {
cin >> x[i] >> f[i];
ll ans = 0;
ll tx = f[i] * modinv(x[i], P) % P;
if (tx == 0) tx = P;
ans = M / P;
if (M % P >= tx) ans++;
cout << ans << endl;
}
}
kobaryo222