結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー chocorusk
提出日時 2018-11-16 23:08:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 813 ms
コンパイル使用メモリ 90,680 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 14:18:24
合計ジャッジ時間 4,034 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll gcd(ll a, ll b){
	if(b==0) return a;
	return gcd(b, a%b);
}
int main()
{
	ll p, q;
	cin>>p>>q;
	ll d=gcd(p, q);
	int n;
	cin>>n;
	int ct=0;
	for(int i=0; i<n; i++){
		ll x, y;
		cin>>x>>y;
		if(p==0 && q==0){
			if(x==0 && y==0) ct++;
		}else{
			if(x%d==0 && y%d==0){
				if((p/d+q/d)%2!=0) ct++;
				else if((x/d+y/d)%2==0) ct++;
			}
		}
	}
	cout<<ct<<endl;
	return 0;
}
0