結果

問題 No.2324 Two Countries within UEC
ユーザー cho435cho435
提出日時 2023-05-28 13:47:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 520 bytes
コンパイル時間 1,941 ms
コンパイル使用メモリ 197,852 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-27 08:26:56
合計ジャッジ時間 9,059 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 260 ms
4,376 KB
testcase_01 AC 269 ms
4,376 KB
testcase_02 AC 49 ms
4,380 KB
testcase_03 AC 200 ms
4,380 KB
testcase_04 AC 231 ms
4,380 KB
testcase_05 AC 52 ms
4,376 KB
testcase_06 AC 92 ms
4,380 KB
testcase_07 AC 42 ms
4,376 KB
testcase_08 AC 198 ms
4,380 KB
testcase_09 AC 202 ms
4,376 KB
testcase_10 AC 272 ms
4,380 KB
testcase_11 AC 263 ms
4,376 KB
testcase_12 AC 81 ms
4,380 KB
testcase_13 AC 81 ms
4,376 KB
testcase_14 AC 49 ms
4,376 KB
testcase_15 AC 42 ms
4,376 KB
testcase_16 AC 181 ms
4,380 KB
testcase_17 AC 117 ms
4,376 KB
testcase_18 AC 52 ms
4,376 KB
testcase_19 AC 269 ms
4,380 KB
testcase_20 AC 35 ms
4,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 270 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  }
}
0