zoukankan      html  css  js  c++  java
  • CodeForces Gym 100935E Pairs

     Pairs
    Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u
     

    Description

    standard input/output
    Statements

    In the secret book of ACM, it’s said: “Glory for those who write short ICPC problems. May they live long, and never get Wrong Answers” . Everyone likes problems with short statements. Right? Let’s have five positive numbers: X1,X2,X3,X4,X5. We can form 10 distinct pairs of these five numbers. Given the sum of each one of the pairs, you are asked to find out the original five numbers.

    Input

    The first line will be the number of test cases T. Each test case is described in one line which contains 10 numbers, these are the sum of the two numbers in each pair. Notice that the input has no particular order, for example: the first number doesn’t have to be equal to {X1+ X2}. All numbers are positive integers below 100,000,000.

    Output

    For each test case, print one line which contains the number of the test case, and the five numbers X1,X2,X3,X4,X5 in ascending order, see the samples and follow the output format. There always exists a unique solution.

    Sample Input

    Input
    2
    15 9 7 15 6 12 13 16 21 14
    12 18 13 10 17 20 21 15 16 14
    Output
    Case 1: 2 4 5 10 11
    Case 2: 4 6 8 9 12


    先把给的数排一下序 在草稿本上写一下 很快就出来了
    设结果从小到大为a b c d e
    第一个数肯定是a+b 最后一个数是d+e 然后c是sum/4-(a+b)-(d+e)


    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <vector>
    #include <iomanip>
    #include <math.h>
    #include <map>
    using namespace std;
    #define FIN     freopen("input.txt","r",stdin);
    #define FOUT    freopen("output.txt","w",stdout);
    #define INF     0x3f3f3f3f
    #define lson    l,m,rt<<1
    #define rson    m+1,r,rt<<1|1
    typedef long long LL;
    
    int num[15];
    
    int main()
    {
        //FIN
        int T;
        scanf("%d",&T);
        for(int z=1;z<=T;z++){
            int sum=0;
            for(int i=1;i<=10;i++){
                scanf("%d",&num[i]);
                sum+=num[i];
            }
            sort(num+1,num+1+10);
            int a,b,c,d,e;
            c=(sum/4)-num[1]-num[10];
            a=num[2]-c;
            b=num[1]-a;
            e=num[9]-c;
            d=num[10]-e;
            printf("Case %d: %d %d %d %d %d
    ",z,a,b,c,d,e);
        }
    }
    

      

  • 相关阅读:
    Atitit.atiJsBridge 新特性v7q329
    atitit.userService 用户系统设计 v6 q413
    atitit.userService 用户系统设计 v6 q413
    Atitit.获取某个服务 网络邻居列表 解决方案
    Hasse神舟笔记本卡logo解决,刷BIOS方法,教你修复神船
    Axure RP 8 注册码
    在本地硬盘安装WinPE系统,实现UEFI引导,摆脱U盘
    cmd实现批量文件的base64加密并双击加密文件后正常运行
    cmd的变量总结
    fiddler几种功能强大的用法
  • 原文地址:https://www.cnblogs.com/Hyouka/p/5754844.html
Copyright © 2011-2022 走看看