結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー minamiminami
提出日時 2019-03-27 11:08:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 947 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 170,524 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-11 02:15:26
合計ジャッジ時間 4,218 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 WA * 26 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int P, Q; cin >> P >> Q;
	int N; cin >> N;
	vector<int> X(N), Y(N); rep(i, 0, N) {
		cin >> X[i] >> Y[i];
	}
	int g = gcd(P + Q, abs(P - Q));
	int ans = 0;
	rep(i, 0, N) {
		if ((X[i] + Y[i]) % g == 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
0