結果

問題 No.849 yuki国の分割統治
ユーザー ttttan2ttttan2
提出日時 2019-07-05 23:57:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,935 bytes
コンパイル時間 1,450 ms
コンパイル使用メモリ 168,912 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-04-16 08:16:34
合計ジャッジ時間 3,699 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 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,948 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 WA -
testcase_07 AC 42 ms
6,940 KB
testcase_08 AC 48 ms
8,448 KB
testcase_09 AC 46 ms
7,808 KB
testcase_10 AC 44 ms
7,168 KB
testcase_11 AC 42 ms
7,424 KB
testcase_12 AC 41 ms
6,944 KB
testcase_13 AC 50 ms
7,936 KB
testcase_14 AC 46 ms
7,552 KB
testcase_15 AC 46 ms
8,064 KB
testcase_16 AC 66 ms
10,496 KB
testcase_17 AC 37 ms
6,940 KB
testcase_18 AC 67 ms
10,752 KB
testcase_19 AC 46 ms
7,424 KB
testcase_20 AC 58 ms
9,216 KB
testcase_21 AC 30 ms
6,944 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 44 ms
7,168 KB
testcase_25 AC 75 ms
11,776 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll n,k,m;
vector<ll> pri;
bool prijud(ll n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll a,b,c,d;cin>>a>>b>>c>>d;
    int n;cin>>n;
    ll x[n],y[n];
    rep(i,0,n)cin>>x[i]>>y[i];
    ll s[n],t[n];
    rep(i,0,n){
        s[i]=x[i]*d-y[i]*c;
        t[i]=y[i]*a-x[i]*b;
    }
    if(a*d==b*c){
        ll u;
        ll uu;
        if(a==0||c==0){
            uu=gcd(b,d);
            u=(b/uu)*a;
            if(u==0)u=(d/uu)*c;
            if(u==0)u=inf;
        }
        else if(b==0||d==0){
            u=gcd(a,c);
            uu=(a/u)*b;
            if(uu==0)uu=(c/u)*d;
            if(uu==0)uu=inf;
        }
        else{
            u=gcd(a,c);
            uu=(a/u)*b;
            if(uu==0)uu=(c/u)*d;
            if(uu==0)uu=inf;
        }
        set<pll> st;
        rep(i,0,n){
            st.insert(make_pair(x[i]%u,y[i]%uu));
        }
        cout<<st.size()<<endl;
        return 0;
    }
    
    set<pll> st;
    rep(i,0,n){
        s[i]%=abs(a*d-b*c);
        t[i]%=abs(a*d-b*c);
        if(s[i]<0)s[i]+=abs(a*d-b*c);
        if(t[i]<0)t[i]+=abs(a*d-b*c);
        st.insert(make_pair(s[i],t[i]));
    }
    
    cout<<st.size()<<endl;
}

0