結果

問題 No.2324 Two Countries within UEC
ユーザー ooaiu
提出日時 2025-09-10 15:45:58
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 2,816 ms
コンパイル使用メモリ 278,452 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-09-10 15:46:06
合計ジャッジ時間 6,537 ms
ジャッジサーバーID
(参考情報)
judge / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using mint = atcoder::modint;
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, m, p, q;
    cin >> n >> m >> p >> q;
    mint::set_mod(p);
    while (q--) {
        int x, f;
        cin >> x >> f;
        if (x % p == 0) {
            cout << (f==0?m:0) << "\n";
            continue;
        }
        long y = (mint(x).inv() * f).val();
        if (m < y) cout << 0 << "\n";
        else {
            int t = (m - y) / p + 1;
            if (y == 0) t--;
            cout << t << "\n";
        }
    }
}
0