CSU——2135: Appositive Body 湖南多校第八场

Description

Yuki Nagato is an alien created by the Data Overmind, and possesses supernatural powers as a result. Two of her abilities are to observe the universe and to transcend time and space.

As we know, it is unstable of the universe if there are more than one active bodies which are actually the same individual at the same time. Nagato defines them as appositive bodies. Of course, Nagato can tell whether there are any appositive bodies of one as soon as she observes.

Now, you become able to travel through time and space by some special chance. But before taking action, you have to make sure you won't destabilize the universe, so you can ask Nagato for some help, including whether there is an appositive body of you at your destination. However, it is inconvenient to make a request every time, so you decide to study this method.

At this time, you are able to describe the universe abstractly, with several points in a 4-dimension vector, which are the space rectangular coordinates xy and z, and the time t. After filtered, these points seem to be in alignment. What you need to do now is to check whether these points are centrosymmetric in four dimensional space. If they are, it means there is your appositive body at your destination.

Input

Input consists of several test cases, for each test case:

First line: a integer n (1 ≤ n ≤ 107), the count of points.

Next n lines: each line has four integers xyzt (−108 ≤ x, y, z, t ≤ 108), the coordinate of a point.

Output

For each test case, output a line: if these points are centrosymmetric in four dimensional space, output "exist". Otherwise, output "not exist".

Sample Input

4
0 0 0 0
-1 0 3 4
4 8 2 2
5 8 -1 -2
3
0 0 0 0
1 1 1 1
1 1 1 1
4
0 0 0 0
1 1 1 1
1 1 1 1
0 0 0 0

Sample Output

exist
not exist
exist

思路:其实这一题重点是理清题意,题目给了我们N个点,问这N个点是否为中心对称,如果是中心对称的话输出exist 否则输出not exist,那么就是判断点是否是中心对称了。那么怎么判断所有的点成中心对称?先假设为中心对称,根据数学知识,中心点的坐标等于所有点的坐标和的平均值,得到中心之后要验证,我们知道所有的点关于一个点成中心对称,那么除了本身就为中心点之后,出现的点一定是成对出现的,不然就不是中心对称了,所以我们求每个点与中心点的坐标之差然后全加起来,由于是对称,所以结果一定是0,不然就没有成对出现就不是中心对称了。

附ac代码:

#include <iostream>
#include <algorithm>
#include <cstring>
#include <stdio.h>
#include <map>
#include <set>
using namespace std;

const int maxn=1000005;
int n;
struct Node
{
    int x,y,z,t;
}node[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin>>n)
    {
        long long sumx=0,sumy=0,sumz=0,sumt=0;
        for(int i=0;i<n;i++)//求中心的坐标
        {
            cin>>node[i].x>>node[i].y>>node[i].z>>node[i].t;
            sumx+=node[i].x;
            sumy+=node[i].y;
            sumz+=node[i].z;
            sumt+=node[i].t;
        }
        long double cx,cy,cz,ct;
        cx=sumx*1.0/n;
        cy=sumy*1.0/n;
        cz=sumz*1.0/n;
        ct=sumt*1.0/n;
        long double tempx=0,tempy=0,tempz=0,tempt=0;//检验是否为中心对称
        for(int i=0;i<n;i++)
        {
            tempx+=(node[i].x-cx);
            tempy+=(node[i].y-cy);
            tempz+=(node[i].z-cz);
            tempt+=(node[i].t-ct);
        }
        if(tempx==0&&tempy==0&&tempz==0&&tempt==0)
            cout<<"exist"<<endl;
        else
            cout<<"not exist"<<endl;
    }
    return 0;
}

/**********************************************************************
	Problem: 2135
	User: jk1601zr
	Language: C++
	Result: AC
	Time:3236 ms
	Memory:17804 kb
**********************************************************************/




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值