結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー satanicsatanic
提出日時 2016-05-21 15:38:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,757 bytes
コンパイル時間 1,707 ms
コンパイル使用メモリ 166,996 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-16 05:45:34
合計ジャッジ時間 3,924 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 AC 31 ms
6,944 KB
testcase_16 AC 13 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 16 ms
6,944 KB
testcase_19 WA -
testcase_20 AC 31 ms
6,944 KB
testcase_21 WA -
testcase_22 AC 7 ms
6,940 KB
testcase_23 AC 27 ms
6,944 KB
testcase_24 AC 8 ms
6,940 KB
testcase_25 WA -
testcase_26 AC 29 ms
6,940 KB
testcase_27 WA -
testcase_28 AC 23 ms
6,940 KB
testcase_29 AC 32 ms
6,944 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 17 ms
6,940 KB
testcase_33 WA -
testcase_34 AC 13 ms
6,940 KB
testcase_35 WA -
testcase_36 AC 3 ms
6,944 KB
testcase_37 AC 20 ms
6,944 KB
testcase_38 AC 16 ms
6,940 KB
testcase_39 WA -
testcase_40 AC 30 ms
6,944 KB
testcase_41 WA -
testcase_42 AC 26 ms
6,940 KB
testcase_43 AC 13 ms
6,944 KB
testcase_44 AC 23 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define VAR(type, a) type a;std::cin>>a;
// VAR(int, x);
#define OUT(d) std::cout<<(d);
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#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 POS std::pair<int, int>
#define IN(a0, y, a1, b0, x, b1) (a0<=y && y<a1 && b0<=x && x<b1)
#define SHOWVECTOR2(v) {std::cout << #v << "\t:\n";for(auto i : v){for(auto j : i){std::cout << j << " ";}std::cout << "\n";}}

#define int ll
using ll = long long;

int GCD(int a, int b){
    return b!=0?GCD(b, a%b):a;
}

signed main(){
    INIT;
    VAR(ll, p)VAR(ll, q)VAR(ll, n);
    std::vector<ll> x(n), y(n);
    REP(i, n){
        std::cin >> x[i] >> y[i];
        x[i] = std::fabs(x[i]);
        y[i] = std::fabs(y[i]);
    }
    int cnt = 0;
    if(p==0 && q==0){
        REP(i, n)if(x[i]==0 && y[i]==0) ++cnt;
    }
    else if(p==0 || q==0){
        int t = std::max(p, q);
        REP(i, n)if(x[i]%t==0 && y[i]%t==0) ++cnt;
    }
    else{
        ll t = GCD(p, q);
        if(p%2==q%2){
            REP(i, n)if(x[i]%t==0 && y[i]%t==0 /*&& (x[i]+y[i])%(t*2)==0*/) ++cnt;
        }
        else{
            REP(i, n)if(x[i]%t==0 && y[i]%t==0) ++cnt;
        }
    }
    OUT(cnt)BR;
    return 0;
}
0