結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー pekempeypekempey
提出日時 2015-12-14 01:17:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,611 bytes
コンパイル時間 1,224 ms
コンパイル使用メモリ 144,460 KB
実行使用メモリ 4,496 KB
最終ジャッジ日時 2023-10-13 16:01:48
合計ジャッジ時間 4,786 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,352 KB
testcase_14 WA -
testcase_15 AC 85 ms
4,348 KB
testcase_16 AC 34 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 15 ms
4,348 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using namespace std;
typedef long long ll;

bool check(ll x, ll y, ll x1, ll y1, ll x2, ll y2) {
	ll D = x1 * y2 - x2 * y1;
	if (D == 0) {
		if (y1 == 0 && x1 == 0) {
			return x == 0 && y == 0;
		}
		if (y1 == 0) {
			if (y != 0) return false;
			return x % x1 == 0;
		}
		if (x1 == 0) {
			if (x != 0) return false;
			return y % y1 == 0;
		}
		if (x % x1 == 0 && y % y1 == 0) {
			return abs(x / x1) == abs(y / y1);
		} else {
			return false;
		}
	} else {
		ll tx = y2 * x - x2 * y;
		ll ty = -y1 * x + x1 * y;
		return tx % D == 0 && ty % D == 0;
	}
}

int main() {
	ll P, Q;
	int N;
	cin >> P >> Q >> N;
	int ans = 0;
	rep (i_, N) {
		ll x, y;
		cin >> x >> y;
		x = abs(x); y = abs(y);
		bool ok = false;
		ok |= check(x, y, P, Q, Q, -P);
		ok |= check(x, y, P, Q, Q, P);
		ok |= check(x, y, Q, P, P, -Q);
		ok |= check(x, y, Q, P, P, Q);
		ok |= check(x, y, P, Q, P, -Q);
		ok |= check(x, y, P, Q, P, Q);
		ok |= check(x, y, Q, P, Q, -P);
		ok |= check(x, y, Q, P, Q, P);
		if (ok) ans++;
	}
	cout << ans << endl;
	return 0;
}
0