結果

問題 No.2324 Two Countries within UEC
ユーザー kotatsugamekotatsugame
提出日時 2023-05-28 13:37:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 64,592 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 06:03:06
合計ジャッジ時間 8,040 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 262 ms
4,376 KB
testcase_01 AC 274 ms
4,376 KB
testcase_02 AC 49 ms
4,376 KB
testcase_03 AC 201 ms
4,380 KB
testcase_04 AC 232 ms
4,376 KB
testcase_05 AC 52 ms
4,380 KB
testcase_06 AC 95 ms
4,376 KB
testcase_07 AC 43 ms
4,380 KB
testcase_08 AC 202 ms
4,376 KB
testcase_09 AC 207 ms
4,376 KB
testcase_10 AC 270 ms
4,376 KB
testcase_11 AC 267 ms
4,376 KB
testcase_12 AC 81 ms
4,376 KB
testcase_13 AC 81 ms
4,380 KB
testcase_14 AC 48 ms
4,384 KB
testcase_15 AC 42 ms
4,380 KB
testcase_16 AC 182 ms
4,376 KB
testcase_17 AC 118 ms
4,376 KB
testcase_18 AC 53 ms
4,376 KB
testcase_19 AC 271 ms
4,380 KB
testcase_20 AC 36 ms
4,380 KB
testcase_21 AC 167 ms
4,376 KB
testcase_22 AC 220 ms
4,376 KB
testcase_23 AC 70 ms
4,384 KB
testcase_24 AC 181 ms
4,380 KB
testcase_25 AC 272 ms
4,376 KB
testcase_26 AC 196 ms
4,376 KB
testcase_27 AC 201 ms
4,380 KB
testcase_28 AC 194 ms
4,380 KB
testcase_29 AC 191 ms
4,380 KB
testcase_30 AC 194 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,376 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,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
int inv(int x,int P)
{
	int b=P-2;
	int e=1;
	while(b)
	{
		if(b&1)e=(long)e*x%P;
		b>>=1;
		x=(long)x*x%P;
	}
	return e;
}
int main()
{
	int N,M,P,Q;
	cin>>N>>M>>P>>Q;
	for(;Q--;)
	{
		int x,f;cin>>x>>f;
		if(x%P==0)
		{
			if(f%P==0)cout<<M<<"\n";
			else cout<<"0\n";
		}
		else
		{
			int y=(long)f*inv(x,P)%P;
			if(y>M)cout<<"0\n";
			else if(y==0)cout<<M/P<<"\n";
			else cout<<(M-y)/P+1<<"\n";
		}
	}
}
0