結果
| 問題 |
No.321 (P,Q)-サンタと街の子供たち
|
| コンテスト | |
| ユーザー |
moti
|
| 提出日時 | 2015-12-15 02:23:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 2,000 ms |
| コード長 | 1,365 bytes |
| コンパイル時間 | 922 ms |
| コンパイル使用メモリ | 101,048 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 22:02:02 |
| 合計ジャッジ時間 | 3,277 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 |
ソースコード
// 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() {
int p, q; cin >> p >> q;
int N; cin >> N;
int ans = 0;
ll g = __gcd(p, q);
if(g > 0) { p /= g, q /= g; }
rep(i, N) {
ll x, y;
cin >> x >> y;
if (p == 0 && q == 0) {
ans += x == 0 && y == 0;
}
else if(x % g == 0 && y % g == 0) {
x /= g, y /= g;
if(p % 2 && q % 2) { // ichimatsu
if((x + y) % 2 == 0) { ans ++; }
}
else {
ans++;
}
}
}
cout << ans << endl;
return 0;
}
moti