結果
| 問題 | 
                            No.321 (P,Q)-サンタと街の子供たち
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-03-09 22:17:52 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 699 bytes | 
| コンパイル時間 | 1,573 ms | 
| コンパイル使用メモリ | 166,360 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-09-18 03:05:05 | 
| 合計ジャッジ時間 | 3,524 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 24 WA * 17 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int P, Q, N, g, ans = 0;
    cin >> P >> Q >> N;
    g = __gcd(P, Q);
    bool flag = false;
    if(g >= 2 && g % 2 == 0){
        flag = (P % g % 2 == Q % g % 2);
    }
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        if(g == 0){
            ans += (x == 0 && y == 0);
            continue;
        }
        if(x % g == 0 && y % g == 0){
            if(flag){
                x /= g, y /= g;
                ans += (x + y) % 2 == 0;
            }else{
                ans++;
            }
        }
    }
    cout << ans << '\n';
}