結果

問題 No.2324 Two Countries within UEC
ユーザー forest3forest3
提出日時 2023-06-15 17:01:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 246 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 1,676 ms
コンパイル使用メモリ 169,504 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 06:27:35
合計ジャッジ時間 8,717 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 234 ms
4,380 KB
testcase_01 AC 244 ms
4,376 KB
testcase_02 AC 44 ms
4,376 KB
testcase_03 AC 179 ms
4,376 KB
testcase_04 AC 210 ms
4,380 KB
testcase_05 AC 46 ms
4,376 KB
testcase_06 AC 83 ms
4,380 KB
testcase_07 AC 38 ms
4,380 KB
testcase_08 AC 183 ms
4,380 KB
testcase_09 AC 188 ms
4,376 KB
testcase_10 AC 244 ms
4,380 KB
testcase_11 AC 240 ms
4,376 KB
testcase_12 AC 73 ms
4,380 KB
testcase_13 AC 74 ms
4,376 KB
testcase_14 AC 44 ms
4,376 KB
testcase_15 AC 38 ms
4,376 KB
testcase_16 AC 162 ms
4,380 KB
testcase_17 AC 103 ms
4,380 KB
testcase_18 AC 48 ms
4,376 KB
testcase_19 AC 242 ms
4,380 KB
testcase_20 AC 32 ms
4,376 KB
testcase_21 AC 158 ms
4,376 KB
testcase_22 AC 203 ms
4,376 KB
testcase_23 AC 66 ms
4,380 KB
testcase_24 AC 170 ms
4,376 KB
testcase_25 AC 246 ms
4,380 KB
testcase_26 AC 191 ms
4,376 KB
testcase_27 AC 197 ms
4,376 KB
testcase_28 AC 190 ms
4,376 KB
testcase_29 AC 190 ms
4,376 KB
testcase_30 AC 190 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/math>
using namespace atcoder;

int main() {
	int N, M, P, Q;
	cin >> N >> M >> P >> Q;
	for( int i = 0; i < Q; i++ ) {
		long long x, f;
		cin >> x >> f;
		if( x % P == 0 ) {
			int ans = 0;
			if( f == 0 ) ans = M;
			cout << ans << endl;
		}
		else {
			long long ix = inv_mod( x, P );
			long long y = f * ix % P;
			int ans = (M - y) / P;
			if( y ) ans++;
			if( y > M ) ans = 0;
			cout << ans << endl;
		}
	}
}
0