結果
| 問題 |
No.2324 Two Countries within UEC
|
| コンテスト | |
| ユーザー |
manjuuu_onsen
|
| 提出日時 | 2023-05-28 16:30:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 249 ms / 2,000 ms |
| コード長 | 540 bytes |
| コンパイル時間 | 1,783 ms |
| コンパイル使用メモリ | 170,884 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 23:27:51 |
| 合計ジャッジ時間 | 8,309 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 41 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;
#include<atcoder/math>
using namespace atcoder;
// #include"debug.hpp"
int main()
{
ll N, M, P, Q;
cin >> N >> M >> P >> Q;
for(int i = 0; i < Q; i++) {
ll x, f; cin >> x >> f;
if(x % P == 0) {
cout << (f == 0 ? M : 0) << endl;
continue;
}
ll y = inv_mod(x, P) * f;
y %= P;
// print(y);
if(y == 0) {
cout << M / P << endl;
}
else if(y > M) cout << 0 << endl;
else cout << (M - y) / P + 1 << endl;;
}
}
manjuuu_onsen