当前位置: 首页 > news >正文

暑假练习赛 007 E - Pairs

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=0;
    scanf("%d",&t);
    for(int l=1;l<=t;l++)
    {
        sum=0;
        for(int i=1;i<=10;i++)
        {
            scanf("%d",&ans[i]);
            sum+=ans[i];
        }
        sum/=4;
        sort(ans+1,ans+11);
        //cout<<sum<<endl;
        cur[3]=sum-ans[1]-ans[10];
        cur[1]=ans[2]-cur[3];
        cur[2]=ans[1]-cur[1];
        cur[5]=ans[9]-cur[3];
        cur[4]=ans[10]-cur[5];
        //cout<<cur[3]<<endl;
        //for(int i=1;i<=5;i++)
        //    printf(" %d",cur[i]);
        //printf("\n");
        sort(cur+1,cur+6);
        printf("Case %d:",l);
        for(int i=1;i<=5;i++)
            printf(" %d",cur[i]);
        printf("\n");
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/5800978.html

相关文章:

  • CodeForces 698A Vacations
  • Zend Studio使用教程之自定义并注册Zend Studio(1/2)
  • EntityFramework 7.0之初探【基于VS 2015】(
  • JAVA之旅(三十五)——完结篇,终于把JAVA写完了,真感概呐!
  • shell脚本中使用alias
  • tomcat常见错误及解决方案
  • rlwrap解决 Oracle sqlplus 在linux 上下文切换乱码问题
  • jquery监听事件on写法以及简单的拖拽效果
  • 配置.pch文件路径。
  • 设计模式之Facade,Adapter, Proxy
  • 使用 Spring Boot 快速构建 Spring 框架应用,PropertyPlaceholderConfigurer
  • 通讯录--(适配iOS7/8/9)
  • delphi关键字
  • JavaScript之面向对象学习五(JS原生引用类型Array、Object、String等等)的原型对象介绍...
  • Bootstrap结合BootstrapTable的使用,分为两种模试显示列表。 自适应表格,自定义行列...
  • 分享的文章《人生如棋》
  • 10个确保微服务与容器安全的最佳实践
  • Angular4 模板式表单用法以及验证
  • AngularJS指令开发(1)——参数详解
  • electron原来这么简单----打包你的react、VUE桌面应用程序
  • Git同步原始仓库到Fork仓库中
  • HTTP 简介
  • HTTP--网络协议分层,http历史(二)
  • Java读取Properties文件的六种方法
  • Java知识点总结(JDBC-连接步骤及CRUD)
  • Mac 鼠须管 Rime 输入法 安装五笔输入法 教程
  • Netty 框架总结「ChannelHandler 及 EventLoop」
  • 百度小程序遇到的问题
  • 近期前端发展计划
  • 理解 C# 泛型接口中的协变与逆变(抗变)
  • 区块链共识机制优缺点对比都是什么
  • 全栈开发——Linux
  • 想晋级高级工程师只知道表面是不够的!Git内部原理介绍
  • 小程序开发中的那些坑
  • 移动互联网+智能运营体系搭建=你家有金矿啊!
  • 3月7日云栖精选夜读 | RSA 2019安全大会:企业资产管理成行业新风向标,云上安全占绝对优势 ...
  • ​ArcGIS Pro 如何批量删除字段
  • ​TypeScript都不会用,也敢说会前端?
  • ​VRRP 虚拟路由冗余协议(华为)
  • # .NET Framework中使用命名管道进行进程间通信
  • #includecmath
  • #QT(智能家居界面-界面切换)
  • $(selector).each()和$.each()的区别
  • (04)Hive的相关概念——order by 、sort by、distribute by 、cluster by
  • (二)学习JVM —— 垃圾回收机制
  • (附源码)基于SpringBoot和Vue的厨到家服务平台的设计与实现 毕业设计 063133
  • (黑客游戏)HackTheGame1.21 过关攻略
  • (九)信息融合方式简介
  • (一)u-boot-nand.bin的下载
  • .CSS-hover 的解释
  • .NET DataGridView数据绑定说明
  • @JsonSerialize注解的使用
  • [.net] 如何在mail的加入正文显示图片
  • [].shift.call( arguments ) 和 [].slice.call( arguments )
  • [20140403]查询是否产生日志