結果
| 問題 |
No.2324 Two Countries within UEC
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-28 13:47:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 520 bytes |
| コンパイル時間 | 1,829 ms |
| コンパイル使用メモリ | 192,800 KB |
| 最終ジャッジ日時 | 2025-02-13 10:18:15 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 WA * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
ll mpow(ll x,ll n,ll mod){
ll res=1;
while(n>0){
if(n&1) res=res*x%mod;
x=x*x%mod;
n>>=1;
}
return res;
}
int main(){
int n,m,p,q;
cin>>n>>m>>p>>q;
rep(Qi,q){
int x,f;
cin>>x>>f;
if(f==0){
if(x%p==0) cout<<m<<endl;
else{
cout<<m/p<<endl;
}
continue;
}
ll res=mpow(x,p-2,p);
res=res*f%p;
cout<<(m+p-res)/p<<endl;
}
}