結果
問題 |
No.2324 Two Countries within UEC
|
ユーザー |
|
提出日時 | 2023-05-28 15:14:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 518 bytes |
コンパイル時間 | 2,113 ms |
コンパイル使用メモリ | 166,084 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 05:31:05 |
合計ジャッジ時間 | 8,416 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 WA * 11 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; ll modinv(ll a,ll m){ ll b=m,u=1,v=0; while(b){ ll t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); } u%=m; if(u<0){ u+=m; } return u; } int main(){ ll n,m,p,q; cin>>n>>m>>p>>q; while(q--){ ll x,f; cin>>x>>f; x%=p; ll inv=modinv(x,p); ll y=f*inv%p; if(y>m){ cout<<0<<endl; }else{ ll cnt=(m-y)/p+1; if(y==0){ cnt--; } cout<<cnt<<endl; } } }