C - Planet Communcation Gym - 101466C (数学)

Lately the communication between planets has been an important issue, which is why the Earth has made many efforts to be connected to every other planet in the universe.

The Universal Network Army of Lasers (UNAL) is trying to connect the Earth with other planets in the universe. In order to make this, the UNAL uses a laser machine which each time it is used, it sends a communication signal in the form of a ray of light in the direction of the planet.

This laser machine is so powerful, that a ray of light generated by it is capable to cross all the planets it touches until the end of the universe. Moreover, when it fires a ray of light in one direction it also fires a ray of light in the opposite direction.

Given the coordinates of all the planets in the universe, help the UNAL to design the way to communicate the Earth with all other planets in the universe using the machine the minimum number of times.

Input

The first line of input contains one integer n (1 ≤ n ≤ 5000), the number of planets.

The next n lines contains the list of coordinates of the planets. In particular, the i - th line contains three integers xiyizi ( - 109 ≤ xi, yi, zi ≤ 109), the coordinates of the i - th planet, respectively. The Earth is the first planet on the list. It is guaranteed that all the planets have different coordinates.

Output

Output a single integer, the minimun number of times the machine should be used to communicate the Earth with all other planets in the universe

Examples

Input

3
0 0 0
1 1 0
-1 -1 0

Output

1

Input

4
0 0 0
1 0 0
0 1 0
0 0 1

Output

3

//Full of love and hope for life

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <map>
#define inf 0x3f3f3f3f
//https://paste.ubuntu.com/
//https://www.cnblogs.com/zzrturist/    //博客园
//https://blog.csdn.net/qq_44134712     //csdn

using namespace std;

typedef long long ll;
const ll maxn=6e7;

ll n[5010],m[5010],s[5010],ss[500010];

int main()
{
    int a,ans=0;
    cin >> a;
    for(int i=1;i<=a;i++){
        cin >> n[i] >> m[i] >> s[i];
    }
    for(int i=2;i<=a;i++){
            if(ss[i]){
                continue;
            }
            ss[i]=1;
            ans++;
            for(int j=i+1;j<=a;j++){
            int x,y,z,x1,y1,z1;
            x=(n[i]-n[1]);
            y=(m[i]-m[1]);
            z=(s[i]-s[1]);
            x1=(n[j]-n[1]);
            y1=(m[j]-m[1]);
            z1=(s[j]-s[1]);
            if(y*z1==y1*z&&x*z1==x1*z&&x*y1==x1*y){
                ss[j]=1;
            }
        }
    }
        cout << ans;
    return 0;
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZZ --瑞 hopeACMer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值