码迷,mamicode.com
首页 > 其他好文 > 详细

toj4119HDFS

时间:2015-06-09 16:12:38      阅读:101      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!