結果

問題 No.849 yuki国の分割統治
ユーザー tempura_pptempura_pp
提出日時 2019-03-28 03:14:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 881 bytes
コンパイル時間 1,877 ms
コンパイル使用メモリ 170,888 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-04-16 07:00:00
合計ジャッジ時間 5,466 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 98 ms
5,376 KB
testcase_08 AC 101 ms
7,296 KB
testcase_09 AC 102 ms
6,400 KB
testcase_10 AC 104 ms
5,888 KB
testcase_11 AC 92 ms
6,400 KB
testcase_12 AC 98 ms
5,632 KB
testcase_13 AC 108 ms
6,784 KB
testcase_14 AC 104 ms
6,144 KB
testcase_15 AC 96 ms
7,168 KB
testcase_16 AC 130 ms
9,216 KB
testcase_17 AC 97 ms
5,376 KB
testcase_18 AC 134 ms
9,344 KB
testcase_19 AC 107 ms
6,016 KB
testcase_20 AC 123 ms
7,936 KB
testcase_21 AC 90 ms
5,376 KB
testcase_22 AC 125 ms
8,704 KB
testcase_23 AC 120 ms
8,192 KB
testcase_24 AC 103 ms
5,632 KB
testcase_25 AC 143 ms
10,496 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;

ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    return b ? gcd(b,a%b) : a;
}
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    int n;
    cin>>n;
    ll x[n],y[n];
    rep(i,n)cin>>x[i]>>y[i];
    map<pair<int,int>,int> mp;
    if(a*d==b*c){
        a=gcd(a,c);
        b=gcd(b,d);
        if(a==0){
            swap(a,b);
            rep(i,n)swap(x[i],y[i]);
        }
        rep(i,n){
            y[i]-=x[i]/a*b;
            x[i]%=a;
            mp[{x[i],y[i]}]++;
        }
    }
    else {
        ll ret=abs(a*d-b*c);
        rep(i,n){
            ll X=((d*x[i]-c*y[i])%ret+ret)%ret;
            ll Y=((-b*x[i]+a*y[i])%ret+ret)%ret;
            mp[{X,Y}]++;
        }
    }
    cout<<mp.size()<<endl;

    return 0;
}
0