結果

問題 No.2324 Two Countries within UEC
ユーザー p3lover
提出日時 2023-05-28 13:58:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 646 bytes
コンパイル時間 757 ms
コンパイル使用メモリ 73,088 KB
実行使用メモリ 1,605,632 KB
最終ジャッジ日時 2024-12-26 22:33:31
合計ジャッジ時間 30,242 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 RE * 13 TLE * 4 MLE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
using ll = long long;

int main() {
    ll N, M, P, Q;
    std::cin >> N >> M >> P >> Q;

    std::vector<ll> modP(M + 1);  // j%P の結果を保持する配列
    for (ll j = 1; j <= M; j++) {
        modP[j] = j % P;
    }

    for (ll i = 0; i < Q; i++) {
        ll x, f;
        std::cin >> x >> f;
        ll ans = 0;

        ll modX = x % P;  // x%P の結果を保持

        for (ll j = 1; j <= M; j++) {
            if ((modP[j] * modX) % P == f) {
                ans++;
            }
        }

        std::cout << ans << std::endl;
    }

    return 0;
}
0