結果

問題 No.2324 Two Countries within UEC
ユーザー hiro71687k
提出日時 2023-06-07 23:45:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 792 bytes
コンパイル時間 4,279 ms
コンパイル使用メモリ 252,864 KB
最終ジャッジ日時 2025-02-13 23:19:38
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=20000000000000;
ll mod=998244353;
int main(){
    ll n,m,p,q;
    cin >> n >> m >> p >> q;
    vector<ll>a;
    for (ll i = 0; i < q; i++)
    {
        ll x,f;
        cin >> x >> f;
        if (x%p==0)
        {
            if (f==0)
            {
                a.push_back(m);
            }else{
                a.push_back(0);
            }
            continue;
        }
        ll z=f*inv_mod(x,p);
        z%=p;
        ll ans=m/p;
        if (z<=m%p&&z!=0)
        {
            ans++;
        }
        a.push_back(ans);
    }
    for (ll i = 0; i < a.size(); i++)
    {
        cout << a[i] <<endl;
    }
    
}
0