結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー SSRSSSRS
提出日時 2020-11-27 07:50:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 726 bytes
コンパイル時間 983 ms
コンパイル使用メモリ 69,376 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-10-01 03:57:21
合計ジャッジ時間 3,493 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 72 ms
4,380 KB
testcase_16 AC 30 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 35 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 71 ms
4,376 KB
testcase_21 WA -
testcase_22 AC 13 ms
4,380 KB
testcase_23 AC 60 ms
4,380 KB
testcase_24 AC 17 ms
4,376 KB
testcase_25 AC 39 ms
4,376 KB
testcase_26 AC 69 ms
4,380 KB
testcase_27 WA -
testcase_28 AC 52 ms
4,376 KB
testcase_29 AC 71 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 36 ms
4,376 KB
testcase_33 WA -
testcase_34 AC 27 ms
4,376 KB
testcase_35 WA -
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 44 ms
4,376 KB
testcase_38 AC 35 ms
4,376 KB
testcase_39 WA -
testcase_40 AC 67 ms
4,376 KB
testcase_41 WA -
testcase_42 AC 58 ms
4,380 KB
testcase_43 AC 30 ms
4,376 KB
testcase_44 AC 52 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int gcd(int a, int b){
	if (b == 0){
		return a;
	} else {
		return gcd(b, a % b);
	}
} 
int main(){
	int P, Q;
	cin >> P >> Q;
	int N;
	cin >> N;
	vector<int> X(N), Y(N);
	for (int i = 0; i < N; i++){
		cin >> X[i] >> Y[i];
	}
	if (P == 0 && Q == 0){
		int ans = 0;
		for (int i = 0; i < N; i++){
			if (X[i] == 0 && Y[i] == 0){
				ans++;
			}
		}
		cout << ans << endl;
	} else {
		int g = gcd(P, Q);
		bool even = false;
		if ((P / g + Q / g) % 2 == 0){
			even = true;
		}
		int ans = 0;
		for (int i = 0; i < N; i++){
			if (X[i] % g == 0 && Y[i] % g == 0 && !(even && (X[i] / g + Y[i] / g) % 2 == 0)){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}
0