結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー 0x19f0x19f
提出日時 2017-09-27 02:20:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 784 bytes
コンパイル時間 1,288 ms
コンパイル使用メモリ 158,576 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 14:22:34
合計ジャッジ時間 3,997 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 AC 79 ms
6,940 KB
testcase_16 AC 31 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 38 ms
6,940 KB
testcase_19 WA -
testcase_20 AC 76 ms
6,940 KB
testcase_21 WA -
testcase_22 AC 14 ms
6,944 KB
testcase_23 AC 63 ms
6,944 KB
testcase_24 AC 16 ms
6,940 KB
testcase_25 WA -
testcase_26 AC 73 ms
6,944 KB
testcase_27 WA -
testcase_28 AC 51 ms
6,944 KB
testcase_29 AC 75 ms
6,940 KB
testcase_30 AC 3 ms
6,944 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 AC 39 ms
6,944 KB
testcase_33 WA -
testcase_34 AC 27 ms
6,940 KB
testcase_35 WA -
testcase_36 AC 3 ms
6,940 KB
testcase_37 AC 48 ms
6,940 KB
testcase_38 AC 38 ms
6,944 KB
testcase_39 WA -
testcase_40 AC 70 ms
6,944 KB
testcase_41 WA -
testcase_42 AC 62 ms
6,944 KB
testcase_43 AC 30 ms
6,940 KB
testcase_44 AC 59 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll P, Q, N, X[100000], Y[100000];
ll g;

ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }

bool ok(ll x, ll y) {
  if(P == 0 && Q == 0) return x == 0 && y == 0;
  if(P == 0 || Q == 0) return x % max(P, Q) == 0 && y % max(P, Q) == 0;
  if(P % 2 == Q % 2) return x % g == 0 && y % g == 0 && (x / g) % 2 == P % 2 && (y / g) % 2 == P % 2;
  return x % g == 0 && y % g == 0;
}

int main(void) {
  cin >> P >> Q >> N;
  REP(i, 0, N) cin >> X[i] >> Y[i];

  if(P != 0 && Q != 0) {
    g = gcd(P, Q);
    P = P / g;
    Q = Q / g;
  }

  // cout << P << " " << Q << endl;

  ll ans = 0;
  REP(i, 0, N) if(ok(X[i], Y[i])) ans++;
  cout << ans << endl;
}
0