結果

問題 No.2324 Two Countries within UEC
ユーザー zezero
提出日時 2023-05-28 14:09:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 2,609 ms
コンパイル使用メモリ 159,352 KB
最終ジャッジ日時 2025-02-13 10:57:04
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
  ll n,m,p,q;
  cin >> n >> m >> p >> q;
  for (int i = 0; i < q;i++){
    ll x,f;
    cin >> x >> f;
    ll inv = pow_mod(x,p-2,p);
    ll y = (inv*f)%p;
    //cout << "y:" << y << endl;
    ll r = m%p;
    ll ans = m/p + (y <= r);
    if (y == 0) ans--;
    cout << ans << endl;
    //cout << m/p << endl;
  }
  
  return 0;
}
0