zoukankan      html  css  js  c++  java
  • toj4119HDFS

    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;
    }
  • 相关阅读:
    Math类操作数据
    java之静态方法与非静态方法
    使用Date和SimpleDateFormat类表示时间
    Java 中基本类型和字符串之间的转换
    Python基础
    生成对抗网络
    机器翻译
    语义角色标注
    个性化推荐
    词向量
  • 原文地址:https://www.cnblogs.com/wos1239/p/4563234.html
Copyright © 2011-2022 走看看