結果
問題 |
No.321 (P,Q)-サンタと街の子供たち
|
ユーザー |
![]() |
提出日時 | 2016-06-06 21:01:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,297 bytes |
コンパイル時間 | 1,559 ms |
コンパイル使用メモリ | 166,736 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-08 16:41:04 |
合計ジャッジ時間 | 5,007 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 WA * 30 RE * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FORR(x,arr) for(auto&& x:arr) #define FOR(i,a,b) for (int i = (a); i < (b); i++) #define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--) #define REP(i,n) for (int i = 0; i < (n); i++) #define RREP(i,n) for (int i = (n)-1; i >= 0; i--) #define ALL(x) (x).begin(), (x).end() #define BIT(n) (1LL<<(n)) #define SZ(x) ((int)(x).size()) #define fst first #define snd second #define DUMP( x ) cerr << #x << " = " << ( x ) << endl typedef long long ll; // ------------------------------------- void Main() { int P, Q; scanf("%d %d", &P, &Q); int N; scanf("%d", &N); int gcd = __gcd(P, Q); P /= gcd; Q /= gcd; P %= 2; Q %= 2; int ans = 0; REP(i, N) { int x, y; scanf("%d %d", &x, &y); if (P == 0 && Q == 0) ans++; else if (P == 0 || Q == 0) ans++; else { // 一般 if (x % gcd == 0 && y % gcd == 0) { // gcd(P,Q) の倍数しかいけない if (P && Q) { // 互いに素にしたP,Qが両方奇数のときはいけない場所がある if ((x + y) % 2) ans++; } else ans++; } } } _P("%d\n", ans); } int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }