結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー ctyl_0
提出日時 2015-12-14 02:30:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 1,225 bytes
コンパイル時間 1,075 ms
コンパイル使用メモリ 83,624 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 12:06:06
合計ジャッジ時間 4,673 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define nil -1
#define mp make_pair
typedef long long ll;
using namespace std;

template <typename T>
inline void output(T a, int p) {
    if(p){
        cout << fixed << setprecision(p)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}
// end of template

int gcd(int a, int b){
    if (b == 0) {
        return a;
    }
    else{
        return gcd(b, a % b);
    }
}

bool judge(int x, int y, int p, int q, int g){
    if (x % g != 0 || y % g != 0 || (x + y) % gcd(p + q, abs(p - q)) != 0) {
        return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    // source code
    
    int P, Q, N;
    cin >> P >> Q >> N;
    int G = gcd(P, Q);
    
    int cnt = 0;
    rep(i, N){
        int x, y;
        cin >> x >> y;
        cnt += judge(x, y, P, Q, G) ? 1 : 0;
    }
    cout << cnt << endl;
    
    return 0;
}
0