結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー mamekin
提出日時 2015-12-19 22:40:57
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 969 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 89,208 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 22:06:50
合計ジャッジ時間 3,172 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

long long gcd(long long a, long long b){
    while(b != 0){
        long long tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

int main()
{
    int p, q, n;
    cin >> p >> q >> n;
    int g = INT_MAX;
    if(p != 0 || q != 0)
        g = gcd(p, q);

    int ans = 0;
    while(--n >= 0){
        int x, y;
        cin >> x >> y;
        if(x % g != 0 || y % g != 0)
            continue;

        x /= g;
        y /= g;
        if((p / g + q / g) % 2 == 0 && (x + y) % 2 != 0)
            continue;

        ++ ans;
    }
    cout << ans << endl;

    return 0;
}
0