結果

問題 No.321 (P,Q)-サンタと街の子供たち
コンテスト
ユーザー Nekosyndrome
提出日時 2015-12-14 07:00:23
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,022 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,797 ms
コンパイル使用メモリ 176,300 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-28 12:03:29
合計ジャッジ時間 3,701 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
bool check(int p,int q,int div,int x,int y)
{
	if(x==0 && y==0) return true;
	if(div==0) return false;
	if(x%div || y%div) return false;

	p /= div;
	q /= div;
	x /= div;
	y /= div;

	if(p%2==0 || q%2==0) return true;
	if(x%2 != y%2) return false;
	return true;
}
int main()
{
	int p,q,gcd;
	int n,x,y;
	int ans;
	while(~scanf("%d %d",&p,&q))
	{
		ans=0;
		p=abs(p);
		q=abs(q);
		gcd = __gcd(p,q);
		RI(n);
		while(n--)
		{
			RI(x,y);
			x = abs(x);
			y = abs(y);
			if(check(p,q,gcd,x,y))
				ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}
0