首页 > 其他 > 详细

toj4119HDFS

时间:2015-06-09 16:10:42      阅读:170      评论:0      收藏:0      [点我收藏+]

In HDFS( Hadoop Distributed File System), each data may have a lot of copies in case of data lose. This problem, every data has its own id, from 1 to n. To make things simple, each data has only two copies. This time, the HDFS is cracked by some stupid reason. Fortunately, tmeteorj knows that there are actually 2 data lost by his keen intuition. Now, it is your time to show your value of life. You should tell tmeteorj the id of lost data.

INPUT

First line, there will a number T(1≤T≤10), means the test case of this problem. After this, each line is first a number n(1≤n≤5000000), means data id is from 1 to n. Then there will be 2(n-1) numbers means the id of data in health state.

OUTPUT

For each case, print the lost id of data. The smaller id is in the front of the bigger one.

Sample Input


3
4 1 1 2 3 4 4
4 1 2 3 1 2 4
4 2 3 4 2 3 1

 

Sample Output


2 3
3 4
1 4

 

Source: TJU School Competetion 2015

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>

using namespace std;

int main()
{
    long long n,i,a,b,x,y,d,z;
    cin>>z;
    while(z--)
    {
        cin>>n;
        a = 2,b = 2;
        for(i = 0;i<2*n-2;i++)
        {
            long long t;
            scanf("%lld",&t);
            a += n-i/2-t;
            b += (n-i/2)*(n-i/2)-t*t;

        }
        d = sqrt(2*b-a*a);
        x = (a-d)/2,y = (a+d)/2;
        cout<<x<<" "<<y<<endl;
    }
    return 0;
}

 

toj4119HDFS

原文:http://www.cnblogs.com/wos1239/p/4563234.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!