結果

問題 No.2324 Two Countries within UEC
ユーザー pengin_2000
提出日時 2023-05-28 13:41:18
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 533 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 29,568 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 21:29:58
合計ジャッジ時間 4,189 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30 WA * 11
権限があれば一括ダウンロードができます

ソースコード

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);
		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