暑假练习赛 007 E - Pairs

时间:2022-03-26 09:54:35
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. SQL 从指定表筛选指定行信息 获取表行数

    1.获取指定表的行数 --获取表中数据行数 --select max([列名]) from 表名 2.筛选指定表的指定行数据(数据表分页获取) http://www.cnblogs.com/morni ...

  2. 利用yii2 gridview实现批量删除案例&lbrack;转&rsqb;

    今天仍然继续探讨GridView的问题,昨天有个小伙伴留言说你用gridview给我去掉表头的链接?我想啊想,这用gridview确实不容易实现,至少我没想出来,会的下方可留言.但是呢,这根gridv ...

  3. XMLA ODBO 以及OLAP服务提供者自定义的协议,我们如何选择

    参考 SAP给他的客户的帮助<ODBO, BAPI and XMLA - Sap>   SAP BW 提供的查询接口: 接口 查询语言 调用接口 OS平台 客户端开发 ODBO MDX C ...

  4. ffmpeg从AVFrame取出yuv数据到保存到char&ast;中

    ffmpeg从AVFrame取出yuv数据到保存到char*中   很多人一直不知道怎么利用ffmpeg从AVFrame取出yuv数据到保存到char*中,下面代码将yuv420p和yuv422p的数 ...

  5. 内存分配函数malloc、realloc、calloc、&lowbar;alloca

    1.内存分配函数_alloca.malloc.realloc.calloc: _alloca 函数原型void * __cdecl _alloca(size_t); 头文件:malloc.h _all ...

  6. UVa 11426 &lpar;欧拉函数 GCD之和&rpar; GCD - Extreme &lpar;II&rpar;

    题意: 求sum{gcd(i, j) | 1 ≤ i < j ≤ n} 分析: 有这样一个很有用的结论:gcd(x, n) = i的充要条件是gcd(x/i, n/i) = 1,因此满足条件的x ...

  7. jira汉化,破解,升级

    交给我这个任务,我先在网络上查了,好些资料,先实验的是6.3.6版本的,这个安装包我是从csdn上下载的.tar.gz的安装,汉化过程也都没有问题.但是在运行过程中不显示下拉菜单,于是我又在官网下载的 ...

  8. openstack kilo版本控制节点异常流量分析

  9. Basic脚本解释器移植到STM32

    本文来自http://blog.csdn.net/hellogv/ .引用必须注明出处! 上次讲了LUA移植到STM32.这次讲讲Basic脚本解释器移植到STM32. 在STM32上跑Basic脚本 ...

  10. Python上下文管理器

    在Python中让自己创建的函数.类.对象支持with语句,就实现了上线文管理协议.我们经常使用with open(file, "a+") as f:这样的语句,无需手动调用f.c ...