結果

問題 No.2324 Two Countries within UEC
ユーザー p3lover
提出日時 2023-05-28 14:03:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 596 bytes
コンパイル時間 1,136 ms
コンパイル使用メモリ 68,736 KB
実行使用メモリ 1,569,536 KB
最終ジャッジ日時 2024-12-26 23:08:04
合計ジャッジ時間 60,604 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 RE * 2 TLE * 9 MLE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

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

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

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

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

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

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

    return 0;
}
0