結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー mamekin
提出日時 2015-12-19 22:38:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 923 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 90,648 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-17 10:57:41
合計ジャッジ時間 4,711 ms
ジャッジサーバーID
(参考情報)
judge6 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39 RE * 2
権限があれば一括ダウンロードができます

ソースコード

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 = 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