結果

問題 No.849 yuki国の分割統治
ユーザー treeonetreeone
提出日時 2019-07-05 22:55:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,586 bytes
コンパイル時間 2,329 ms
コンパイル使用メモリ 204,752 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-04-16 07:58:20
合計ジャッジ時間 5,536 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 98 ms
6,944 KB
testcase_09 AC 98 ms
6,944 KB
testcase_10 AC 95 ms
6,944 KB
testcase_11 AC 87 ms
6,940 KB
testcase_12 AC 84 ms
6,940 KB
testcase_13 AC 109 ms
6,940 KB
testcase_14 AC 92 ms
6,940 KB
testcase_15 AC 83 ms
6,940 KB
testcase_16 AC 171 ms
8,576 KB
testcase_17 AC 132 ms
6,940 KB
testcase_18 AC 174 ms
8,832 KB
testcase_19 AC 133 ms
6,940 KB
testcase_20 AC 181 ms
6,944 KB
testcase_21 AC 39 ms
6,940 KB
testcase_22 AC 94 ms
6,948 KB
testcase_23 AC 80 ms
6,944 KB
testcase_24 AC 76 ms
6,940 KB
testcase_25 AC 150 ms
9,984 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;
const int mod = 1000000007;
const int INF = 1e18;

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int n;
    cin >> n;
    if(a * d - b * c == 0){
        set<P> st;
        rep(i, 0, n){
            int x, y;
            cin >> x >> y;
            P v;
            v.first = a * y - b * x;
            v.second = a;
            int G = gcd(abs(v.first), abs(v.second));
            v.first /= G;
            v.second /= G;
            st.insert(v);
        }
        cout << st.size() << endl;
        return 0;
    }
    set<PP> st;
    rep(i, 0, n){
        int x, y;
        cin >> x >> y;
        P u, v;
        u.second = v.second = a * d - b * c;
        u.first = d * x - c * y;
        v.first = a * y - b * x;
        if(u.second < 0){
            u.first *= -1;
            u.second *= -1;
            v.first *= -1;
            v.second *= -1;
        }
        int G = gcd(abs(u.first), abs(u.second));
        u.first /= G;
        u.second /= G;
        u.first = (u.first % u.second + u.second) % u.second;
        G = gcd(abs(v.first), abs(v.second));
        v.first /= G;
        v.second /= G;
        v.first = (v.first % v.second + v.second) % v.second;
        st.insert({u, v});
    }
    cout << st.size() << endl;
}
0