結果

問題 No.2324 Two Countries within UEC
ユーザー pengin_2000pengin_2000
提出日時 2023-05-28 13:55:41
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 841 ms
コンパイル使用メモリ 28,528 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 06:09:31
合計ジャッジ時間 4,694 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
4,380 KB
testcase_01 AC 95 ms
4,376 KB
testcase_02 AC 17 ms
4,380 KB
testcase_03 AC 69 ms
4,376 KB
testcase_04 AC 78 ms
4,380 KB
testcase_05 AC 18 ms
4,376 KB
testcase_06 AC 31 ms
4,376 KB
testcase_07 AC 14 ms
4,376 KB
testcase_08 AC 65 ms
4,376 KB
testcase_09 AC 67 ms
4,376 KB
testcase_10 AC 95 ms
4,376 KB
testcase_11 AC 88 ms
4,380 KB
testcase_12 AC 28 ms
4,380 KB
testcase_13 AC 27 ms
4,380 KB
testcase_14 AC 17 ms
4,376 KB
testcase_15 AC 15 ms
4,380 KB
testcase_16 AC 64 ms
4,376 KB
testcase_17 AC 41 ms
4,380 KB
testcase_18 AC 18 ms
4,376 KB
testcase_19 AC 94 ms
4,376 KB
testcase_20 AC 12 ms
4,376 KB
testcase_21 AC 40 ms
4,380 KB
testcase_22 AC 52 ms
4,380 KB
testcase_23 AC 16 ms
4,376 KB
testcase_24 AC 42 ms
4,384 KB
testcase_25 AC 93 ms
4,380 KB
testcase_26 AC 31 ms
4,376 KB
testcase_27 AC 33 ms
4,376 KB
testcase_28 AC 31 ms
4,380 KB
testcase_29 AC 30 ms
4,380 KB
testcase_30 AC 31 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 0 ms
4,376 KB
testcase_37 AC 0 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 0 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
long long int modpow(long long int a, long long int n, long long int p)
{
	long long int res = 1;
	for (; n > 0; n /= 2, a = a * a % p)
		if (n % 2 > 0)
			res = res * a % p;
	return res;
}
int main()
{
	long long int n, m, p, q;
	scanf("%lld %lld %lld %lld", &n, &m, &p, &q);
	long long int y;
	long long int x, f;
	long long int ans;
	for (; q > 0; q--)
	{
		scanf("%lld %lld", &x, &f);
		if (x % p == 0)
		{
			if (f == 0)
				ans = m;
			else
				ans = 0;
		}
		else
		{
			y = f * modpow(x, p - 2, p) % p;
			ans = m / p;
			if (y <= m % p && y != 0)
				ans++;
		}
		printf("%lld\n", ans);
	}
	return 0;
}
0