宇宙通信

CF-101466-C

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 xi, yi, zi ( - 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


题意:

从地球向外发射激光,能穿透一切,每次发射的激光都是双向的,即直线而不是射线。
n n 个星球(包括地球)问需要多少激光。
输入n然后n个三维坐标

做法:

每次输入一个点都变成一个以地球为起点,当前点为终点的向量
然后在一个一开始为空的vector<向量>中for 每个向量,如果没有与之共线的向量则放入这个数组
否则跳过,这样vector的size即为需要的激光数。
PS:向量共线坐标判断:
在一个平面内

{a1=(x1,y1)a2=(x2,y2)

if a1||a2 if   a 1 → | | a 2 →
x1×y2=x2×y1 x 1 × y 2 = x 2 × y 1

空间内就是三个平面的分解向量分别平行
{a1=(x1,y1,z1)a2=(x2,y2,z2) { a 1 → = ( x 1 , y 1 , z 1 ) a 2 → = ( x 2 , y 2 , z 2 )
if a1||a2 if   a 1 → | | a 2 →
x1×y2=x2×y1y1×z2=y2×z1z1×x2=z2×x1 { x 1 × y 2 = x 2 × y 1 y 1 × z 2 = y 2 × z 1 z 1 × x 2 = z 2 × x 1

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct point
{
    ll x, y, z;
    bool paralel(const point& b)
    {
        if (x*b.y == y * b.x)
            if (x*b.z == b.x*z)
                if (y*b.z == b.y*z)
                return true;
        return false;
    }
};
vector<point>v;
int main()
{
    int n;
    cin >> n;
    v.clear();
    point earth;
    cin >> earth.x >> earth.y >> earth.z;
    point t;
    for (int i = 1; i < n; i++)
    {
        cin >> t.x >> t.y >> t.z;
        t.x -= earth.x;
        t.y -= earth.y;
        t.z -= earth.z;
        bool flag = true;
        for (int j = 0; j < v.size(); j++)
        {
            if (t.paralel(v[j]))
            {
                flag = false;
                break;
            }
        }
        if (flag)
            v.push_back(t);
    }
    cout << v.size() << endl;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值