結果
| 問題 |
No.2324 Two Countries within UEC
|
| コンテスト | |
| ユーザー |
kpinkcat
|
| 提出日時 | 2023-09-26 23:47:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 810 bytes |
| コンパイル時間 | 1,762 ms |
| コンパイル使用メモリ | 194,084 KB |
| 最終ジャッジ日時 | 2025-02-17 02:33:38 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 33 |
ソースコード
#include <bits/stdc++.h>
#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
#include<string>
using ll = long long;
using namespace std;
int main()
{
ll n, m, p, q;
cin >> n >> m >> p >> q;
for (int i = 0; i < q; i++){
ll x, f, x1 = 1, p1, y;
cin >> x >> f;
if (!(x%p) && f == 0){
cout << m << endl;
return 0;
} else if (!(x%p)){
cout << 0 << endl;
return 0;
}
p1 = p - 2;
while (p1){
if (p1 & 1) x1 *= x;
x *= x;
x %= p;
p1 >>= 1;
}
y = x1 * f % p;
if (!y) cout << m/p << endl;
else cout << (m - y + p)/p << endl;
}
}
kpinkcat