結果

問題 No.2324 Two Countries within UEC
ユーザー m_99m_99
提出日時 2023-05-28 13:37:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 3,818 ms
コンパイル使用メモリ 227,088 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 06:02:23
合計ジャッジ時間 10,670 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 233 ms
4,380 KB
testcase_01 AC 246 ms
4,376 KB
testcase_02 AC 45 ms
4,376 KB
testcase_03 AC 182 ms
4,380 KB
testcase_04 AC 210 ms
4,380 KB
testcase_05 AC 47 ms
4,380 KB
testcase_06 AC 82 ms
4,376 KB
testcase_07 AC 39 ms
4,380 KB
testcase_08 AC 185 ms
4,376 KB
testcase_09 AC 187 ms
4,380 KB
testcase_10 AC 242 ms
4,376 KB
testcase_11 AC 239 ms
4,380 KB
testcase_12 AC 74 ms
4,376 KB
testcase_13 AC 73 ms
4,380 KB
testcase_14 AC 44 ms
4,376 KB
testcase_15 AC 38 ms
4,380 KB
testcase_16 AC 165 ms
4,376 KB
testcase_17 AC 105 ms
4,376 KB
testcase_18 AC 48 ms
4,380 KB
testcase_19 AC 250 ms
4,380 KB
testcase_20 AC 31 ms
4,376 KB
testcase_21 AC 162 ms
4,376 KB
testcase_22 AC 207 ms
4,376 KB
testcase_23 AC 66 ms
4,376 KB
testcase_24 AC 170 ms
4,376 KB
testcase_25 AC 241 ms
4,380 KB
testcase_26 AC 188 ms
4,380 KB
testcase_27 AC 200 ms
4,380 KB
testcase_28 AC 192 ms
4,380 KB
testcase_29 AC 188 ms
4,376 KB
testcase_30 AC 192 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main(){
	
	int N,M;
	cin>>N>>M;
	int P,Q;
	cin>>P>>Q;
	rep(i,Q){
		int x,y;
		cin>>x>>y;
		if(y==0){
			if(x%P==0){
				cout<<M<<endl;
			}
			else{
				cout<<M/P<<endl;
			}
		}
		else{
			if(x%P==0){
				if(y==0){
				cout<<M<<endl;
				continue;
				}
				else{
					cout<<0<<endl;
					continue;
				}
			}
			long long t = y;
			t *= inv_mod(x,P);
			t %= P;
		//	cout<<t<<endl;
			long long ans = M/P;
			if(M%P>=t)ans++;
			cout<<ans<<endl;
		}
	}
	
	return 0;
}
0