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
215 9 7 15 6 12 13 16 21 1412 18 13 10 17 20 21 15 16 14

Output
Case 1: 2 4 5 10 11Case 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()
{//FINint 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\n",z,a,b,c,d,e);}
}

  

转载于:https://www.cnblogs.com/Hyouka/p/5754844.html

CodeForces Gym 100935E Pairs相关推荐

  1. E - Pairs Gym - 100935E

    E - Pairs Gym - 100935E 题意:已知五个数的相互相加的和,这十个数均不同,求这五个数的值. In the secret book of ACM, it's said: " ...

  2. Codeforces Gym 101173 CERC 16 D BZOJ 4790 Dancing Disks

    Codeforces Gym 101173 CERC 16 D & BZOJ 4790 Dancing Disks 强烈安利这道构造题目,非常有意思. 这里用到的思想是归并排序! 多路归并排序 ...

  3. Codeforces Gym 101086 M ACPC Headquarters : AASTMT (Stairway to Heaven)

    Codeforces Gym 101086 M ACPC Headquarters : AASTMT (Stairway to Heaven) 题目来源: Codeforces 题意: 给出一些比赛, ...

  4. [Codeforces Gym 101651/100725B] Banal Tickets

    Codeforces Gym 100725 题解: 先分两种情况, 积为000与积非0" role="presentation" style="position ...

  5. Codeforces Gym 100463A Crossings 逆序数

    Crossings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463 Description ...

  6. Codeforces gym 2013-2014 Samara SAU ACM ICPC Quarterfinal Qualification Contest

    题目地址:http://codeforces.com/gym/100247 2014.10.27版 26号训练的题,今天发现A题有更高效的解法,用到了前缀最大值和后缀最大值 A. The Power ...

  7. Codeforces Gym 100114 H. Milestones 离线树状数组

    H. Milestones Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descripti ...

  8. Codeforces Gym 100513G G. FacePalm Accounting 暴力

    G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513 ...

  9. Codeforces Gym 100269 Dwarf Tower (最短路)

    题目连接: http://codeforces.com/gym/100269/attachments Description Little Vasya is playing a new game na ...

  10. Codeforces Gym 100676G Training Camp 状压dp

    http://codeforces.com/gym/100676 题目大意是告诉你要修n门课,每门课有一个权值w[i], 在第k天修该课程讲获得k*w[i]的学习点数,给出了课程与先修课程的关系,要修 ...

最新文章

  1. 2017 省赛选拨 想打架吗?算我一个!所有人,都过来!(3) 递推 斐波拉数列的应用...
  2. 如何从手机或PC将游戏下载到PlayStation 4
  3. 为List配置一个搜索按钮
  4. 基于 Redis3.2.4 集群搭建说明
  5. 局域网摄像头扫描_使用Pyhton带你分析酒店里的针孔摄像头
  6. 【比赛】CCL“中国法研杯”相似案例匹配评测竞赛 - TOP队伍攻略分享
  7. iOS could not set nil as the value for the key
  8. 微信小程序开发的完整人性化版攻略
  9. AI 人工智能之概率论基础(概念总结和复习)
  10. javascript 表单提交和验证的方法
  11. LSB 算法matlab改进版,将二值图嵌入多张灰度图像中
  12. 【网页期末作业】用HTML+CSS做一个漂亮简单的学校官网
  13. 自助分析重新定义大宗商品交易
  14. HTML Purifier 4.3.0
  15. 做高新技术企业申请,一定要知识产权吗?
  16. TapTap物理画线游戏,使用Unity实现2D物理画线功能
  17. 兼容IE的excel下载
  18. 【LOJ573】「LibreOJ NOI Round #2」单枪匹马(矩阵乘法)
  19. Excel数据导入到hbase实战
  20. 进制的转换,ipv4

热门文章

  1. python统计图的三层结构设计代码_【Python数据可视化】用Matplotlib绘制常见统计图,中文显示字体任意设置...
  2. 应用动态html教学反思,12月份教学反思:百分数的应用(一)反思
  3. mysql数据库优化语句_MySQL优化之三:SQL语句优化
  4. Python进阶(十二)常用数据处理模块
  5. 人脸识别 Face Recognition安装使用
  6. 专题训练——[kuangbin带你飞]最短路练习
  7. Python基础:字典(dict)与集合(set)
  8. csapp第八章 异常控制流
  9. 现代软件工程——第一周博客作业
  10. Java基础系列--static关键字