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. AngularJS -- Bootstrap(启动器)

    点击查看AngularJS系列目录 转载请注明出处:http://www.cnblogs.com/leosx/ Bootstrap(初始化) 这章介绍了Angular的初始化过程,以及如何在必要的时候 ...

  2. Raspiberry Camera详解+picamera库+Opencv控制

    使用树莓派的摄像头,将树莓派自身提供的picamera的API数据转换为Python Oencv可用图像数据: # import the necessary packages from picamer ...

  3. Tomcat启动错误【Error listenerStart】

    今天启动Tomcat启动不了,报以下错: org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerSt ...

  4. postman - 基本操作

    设置环境 collections 导入 runner 导入 api 配置api 编写测试(请求和响应)脚本 api的保存和导出 setting file -- setting

  5. iKcamp出品|全网最新|微信小程序|基于最新版1.0开发者工具之初中级培训教程分享

  6. JS在可编辑的div中的光标位置插入内容或表情

    <input type="button" value="插入字符" onclick="document.getElementById('test ...

  7. DataRow和DataRowView的区别

    可以将DataView同数据库的视图类比,不过有点不同,数据库的视图可以跨表建立视图,DataView则只能对某一个DataTable建立视图. DataView一般通过DataTable.Defau ...

  8. win10 uwp 入门

    UWP是什么我在这里就不说,本文主要是介绍如何入门UWP,也是合并我写的博客. 关于UWP介绍可以参见:http://lib.csdn.net/article/csharp/32451 首先需要申请一 ...

  9. 在SQL Server中实现关系模型的阶梯到级别3的t -SQL DML

    在SQL Server中实现关系模型的阶梯到级别3的t -SQL DML 格雷戈里·拉森(Gregory Larsen),2017/08/02(第一次出版:2011 /11/09) 原文链接:http ...

  10. C语言指针的那些坑

    那些年把我们坑惨的指针 一.引言 当我们使用c语言的时候,不可避免的就得用到指针,然后对于刚刚接触C语言的猿兄们,可能会有点不适应,特别是刚刚从python等离硬件很远的语言转过来的. 下面我为大家总 ...