CSU - 2135 Appositive Body

当时在现场赛的时候 学长说这题可以做做看

因为其他队伍有马上AC的 

但是是全英文的,又不是很理解,只能说了解了一个大概吧......

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

Hint

centrosymmetric [adj.] 中心对称的


题意:

给出 n 个数据的 x,y,z,t的值, 判断这 n 个值构成的立体图形是否为中心对称图形

是中心对称图形就输出 “exist” 否则,就输出 “not exist”

理解:

判断中心对称图形

首先找到中心对称点

计算各个点到中心对称点的距离 (保留正负)

将这些距离相加 和值为0 

则是中心对称图形


放一下AC的代码

(CE了好多次  重点是 注意数据范围 把数据类型设置成 long  double 和 long  long)

#include <stdio.h>>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
using namespace std;
#define maxn 1000005
const double mm=1e-9;
struct node
{
    long long x,y,z,t;
    node() {}
} m[maxn];
long double a,b,c,d;
long double x2,y2,z2,t2;
int main()
{
    int kk;
    while (~scanf("%d",&kk))
    {
        a=b=c=d=0;//一定要初始化!
        x2=y2=z2=t2=0;
        long long sumx=0,sumy=0,sumz=0,sumt=0;//特别是初始为0的值
        memset(m,0,sizeof m);
        for (int i=0; i<kk; i++)
        {
            scanf("%lld%lld%lld%lld",&m[i].x,&m[i].y,&m[i].z,&m[i].t);
            sumx+=m[i].x;
            sumy+=m[i].y;
            sumz+=m[i].z;
            sumt+=m[i].t;
        }
        a=sumx*1.0/kk;//得到中心对称点
        b=sumy*1.0/kk;
        c=sumz*1.0/kk;
        d=sumt*1.0/kk;
        for (int i=0; i<kk; i++)//将各个点到中心对称点的距离相加
        {
            x2+=(a-m[i].x);
            y2+=(b-m[i].y);
            z2+=(c-m[i].z);
            t2+=(d-m[i].t);
        }
        if (x2==0&&y2==0&&z2==0&&t2==0)
            printf("exist\n");
        else printf("not exist\n");
    }
    return 0;
}

这篇博客真的写了好几天的赶脚 X﹏X

因为当时审题之后 没有好好地思考 

(当时想的是 最远的两点间的位置为中心对称点 这个思想错了 而且样例太好过了啊 (゚Д゚*)ノ......)

数学题还是要多分析一下



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值