結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー snukesnuke
提出日時 2015-12-15 00:24:02
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,693 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 73,628 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 16:52:57
合計ジャッジ時間 3,305 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
#define drep(i,n) for(int i = n-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}

const int MX = 100005, INF = 1000010000;
const ll LINF = 1000000000000000000ll;
const double eps = 1e-10;

ll gcd(ll x,ll y) { return y?gcd(y,x%y):x;}
ll lcm(ll x, ll y) { return x/gcd(x,y)*y;}

int main() {
  int p, q;
  int n;
  scanf("%d%d%d",&p,&q,&n);
  int g = gcd(p,q);
  p /= g; q /= g;
  int ans = 0;
  rep(i,n) {
    int x, y;
    scanf("%d%d",&x,&y);
    x = abs(x);
    y = abs(y);
    if (x%g || y%g) continue;
    x /= g;
    y /= g;
    if (x+y&1) {
      if (p+q&1) ++ans;
    } else ++ans;
  }
  cout<<ans<<endl;
  return 0;
}




0