E - Pairs

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
/*
数学题5个数任意组合出十个数,给出你这10个数,让你求出原始的5个数 推理 x1+x2一定=s1 s4+s5=s10
得出x3=sum-s1-s10;
sum就是5个数的和,这十个数,五个中每个数字用4次
然后解方程就可以了
*/
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<map>
#define N 11
using namespace std;
int main()
{
//freopen("in.txt","r",stdin);
int t;
int ans[N];
int cur[N];
long long sum=;
scanf("%d",&t);
for(int l=;l<=t;l++)
{
sum=;
for(int i=;i<=;i++)
{
scanf("%d",&ans[i]);
sum+=ans[i];
}
sum/=;
sort(ans+,ans+);
//cout<<sum<<endl;
cur[]=sum-ans[]-ans[];
cur[]=ans[]-cur[];
cur[]=ans[]-cur[];
cur[]=ans[]-cur[];
cur[]=ans[]-cur[];
//cout<<cur[3]<<endl;
//for(int i=1;i<=5;i++)
// printf(" %d",cur[i]);
//printf("\n");
sort(cur+,cur+);
printf("Case %d:",l);
for(int i=;i<=;i++)
printf(" %d",cur[i]);
printf("\n");
}
return ;
}

暑假练习赛 007 E - Pairs的更多相关文章

  1. 暑假练习赛 007 C - OCR

    C - OCR Description standard input/outputStatements Optical Character Recognition (OCR) is one of th ...

  2. 暑假练习赛 007 B - Weird Cryptography

    Weird Cryptography Description standard input/outputStatements Khaled was sitting in the garden unde ...

  3. 暑假练习赛 007 A - Time

    A - Time Description standard input/outputStatements A plane can go from city X to city Y in 1 hour ...

  4. 暑假练习赛 003 F Mishka and trip

    F - Mishka and trip Sample Output   Hint In the first sample test: In Peter's first test, there's on ...

  5. 暑假练习赛 006 E Vanya and Label(数学)

    Vanya and LabelCrawling in process... Crawling failed Time Limit:1000MS     Memory Limit:262144KB    ...

  6. 暑假练习赛 003 B Chris and Road

    B - Chris and Road Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144K ...

  7. 暑假练习赛 003 A Spider Man

    A - Spider Man Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB    ...

  8. 暑假练习赛 006 B Bear and Prime 100

    Bear and Prime 100Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:262144KB ...

  9. 暑假练习赛 006 A Vanya and Food Processor(模拟)

    Description Vanya smashes potato in a vertical food processor. At each moment of time the height of ...

随机推荐

  1. day16<集合框架+>

    集合框架(去除ArrayList中重复字符串元素方式) 集合框架(去除ArrayList中重复自定义对象元素) 集合框架(LinkedList的特有功能) 集合框架(栈和队列数据结构) 集合框架(用L ...

  2. asp.net mvc项目实记-开启伪静态-Bundle压缩css,js

    百度这些东西,还是会浪费了一些不必要的时间,记录记录以备后续 一.开启伪静态 如果不在web.config中配置管道开关则伪静态无效 首先在RouteConfig.cs中中注册路由 routes.Ma ...

  3. thinkphp的select和find的区别

    hinkphp是比较好的php开发框架,能比较快速的开发MVC架构的管理系统,我们需要用到 select()和find()方法,两个方法都能返回数据集数组,但有什么不同呢?先看一下我的代码对比:$te ...

  4. 第6章 Overlapped I/O, 在你身后变戏法 ---被激发的 File Handles -3

    最简单的 overlapped I/O 类型,是使用它自己的文件 handle 作为同步机制.首先你以 FILE_FLAG_OVERLAPPED 告诉 Win32 说你不要使用默认的同步 I/O.然后 ...

  5. class DELPHICLASS TObject

    class DELPHICLASS TObject    1.自己猜想:delphi,是windows平台的快速应用程序开发工具Rapid Application Development 简称RAD. ...

  6. Reshape the Matrix

    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...

  7. input中range相关操作

    利用mousover触发函数对range的操作练习 <!DOCTYPE html> <html> <head> <meta charset="utf ...

  8. 简单Elixir游戏服设计-玩家进程跑起来

    有了玩家模型,我们试试让玩家进程跑起来. 需要搞个PlayerSupervisor来负责启动和监控玩家进程. defmodule PlayerSupervisor do use Supervisor ...

  9. 理解js中的运算符优先级

    前言 我是有过这样的经历,获取年月日时写出这样的代码: new Date().getFullYear() 此时的我是心虚的,因为我不知道是先执行.运算还是new运算,于是赶紧贴到控制台里,哎呦

  10. 实现mysql在windows server 2008下自动备份

    环境:MySQL   安装位置:D:\MySQL论坛数据库名称为:Db_Test数据库备份目的地:D:\db_bak\ 1.首先新建一个bat文件 rem ********************** ...