結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー motimoti
提出日時 2015-12-15 01:39:59
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,445 bytes
コンパイル時間 743 ms
コンパイル使用メモリ 98,260 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 16:55:22
合計ジャッジ時間 4,288 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 RE -
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 36 ms
4,348 KB
testcase_15 AC 79 ms
4,348 KB
testcase_16 AC 33 ms
4,352 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 39 ms
4,348 KB
testcase_19 AC 51 ms
4,348 KB
testcase_20 AC 78 ms
4,348 KB
testcase_21 AC 47 ms
4,352 KB
testcase_22 AC 14 ms
4,348 KB
testcase_23 AC 65 ms
4,348 KB
testcase_24 WA -
testcase_25 AC 43 ms
4,348 KB
testcase_26 WA -
testcase_27 AC 56 ms
4,348 KB
testcase_28 WA -
testcase_29 AC 79 ms
4,348 KB
testcase_30 AC 3 ms
4,352 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 40 ms
4,348 KB
testcase_33 AC 39 ms
4,352 KB
testcase_34 WA -
testcase_35 AC 61 ms
4,352 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 12 ms
4,352 KB
testcase_40 WA -
testcase_41 AC 20 ms
4,348 KB
testcase_42 AC 64 ms
4,352 KB
testcase_43 WA -
testcase_44 AC 58 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// see also: SRM 564 Div2 Hard KnightCircuit  / ナイトツアー
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define minimize(a, x) a = std::min(a, x)
#define maximize(a, x) a = std::max(a, x)

template<class T> constexpr bool in_range(T y, T x, T H, T W) { return -H<=y&&y<H&&-W<=x&&x<W; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  ll p, q; cin >> p >> q;
  ll g = 1;
  if(p > 0 && q > 0) {
    g = __gcd(p, q);
  }
  else {
    g = max(p, q);
  }

  int ans = 0;
  int N; cin >> N;

  rep(i, N) {

    ll x, y; cin >> x >> y;
    if(x < 0) x *= -1;
    if(y < 0) y *= -1;

    if(x % g) continue;
    if(y % g) continue;

    x /= g, y /= g;

    if(p == 0 && q == 0) {
      if(x == 0 && y == 0) {
        ans ++;
      }
    }
    else if((p + q) % 2) {
      ans ++;
    }
    else if((x + y) % 2 == 0) {
      ans ++;
    }

  }

  cout << ans << endl;

  return 0;
}
0