E - Pairs Gym - 100935E

题意:已知五个数的相互相加的和,这十个数均不同,求这五个数的值。
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.

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
题解:这十个数最小的是a+b,最大的是d+e,易得
c = sum/4-(a+b)-(d+e); 剩下的易推。

#include<bits/stdc++.h>
using namespace std;int main()
{int t;cin >> t;for(int k = 1; k <= t; k ++){int a, b, c, d, e;int sum[11];int num = 0;for(int i = 0; i < 10; i ++){cin >> sum[i];num+=sum[i];}sort(sum, sum+10);c = num/4-sum[0]-sum[9];a = sum[1] - c;b = sum[0] - a;e = sum[8] - c;d = sum[9] - e;printf("Case %d: ", k);cout << a << ' ' << b << ' ' << c <<' ' << d <<' ' << e <<endl;}return 0;
}

E - Pairs Gym - 100935E相关推荐

  1. I - Por Costel and the Pairs Gym - 100923I _思维啊——可惜我现在还没

    We don't know how Por Costel the pig arrived at FMI's dance party. All we know is that he did. The d ...

  2. Codeforces Gym 100463A Crossings 逆序数

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

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

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

  4. gym.wrappers介绍

    原地址:https://blog.csdn.net/u013745804/article/details/78403353 gym wrappers用于将环境进行打包,我们可以使用这个模块来记录自己的 ...

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

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

  6. Pairs Forming LCM LightOJ - 1236

    Pairs Forming LCM LightOJ - 1236 题意 问共有多少组数的最大公约数是n 分析 组合数学 ,唯一分解定理 参考代码 int Prime[670000]; const in ...

  7. 强化学习(三) - Gym库介绍和使用,Markov决策程序实例,动态规划决策实例

    强化学习(三) - Gym库介绍和使用,Markov决策程序实例,动态规划决策实例 1. 引言 在这个部分补充之前马尔科夫决策和动态规划部分的代码.在以后的内容我会把相关代码都附到相关内容的后面.本部 ...

  8. Gym - 102082G

    Gym - 102082G https://vjudge.net/problem/2198225/origin 对于数列中任意一个数,要么从最左边到它不递减,要么从最右边到到它不递减,为了满足这个条件 ...

  9. 373. Find K Pairs with Smallest Sums (java,优先队列)

    题目: You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Def ...

最新文章

  1. 在抖音推荐算法组工作的体验
  2. 生物信息通识技术研讨会
  3. 两个列表之间移动数据
  4. 在已有SQL 2005 Server 群集中添加节点
  5. java程序运行时,数据的存储地!
  6. 一个大图切成几个小图加载速度更快_CSS精灵图技术(提高页面的加载速度)
  7. 刘宏伟计算机组成,哈工大组成原理和数据结构 ppt 计算机组成原理刘宏伟 版本一 第18讲...
  8. 整理了5个JavaScript怪异行为及其原因
  9. html5中defer的属性,HTML5中defer和async的比较
  10. c语言编程sinx泰勒公式_大白话5分钟带你走进人工智能-第12节梯度下降之原理泰勒公式(7)...
  11. 如何使用启动盘PE桌面工具安装原版win7系统?
  12. CyberSecurity Knowledge Base笔记
  13. JAVA 获取某天、某周、某月、某年的开始时间和结束时间
  14. 项目部署三---linux下Nginx安装
  15. 基于JAVAweb开发数码产品推荐平台系统设计与实现计算机毕业设计源码+数据库+lw文档+系统+部署
  16. 卷积神经网络如何识别图像
  17. P6软件设置OBS组织分解结构
  18. mac+os+lion+安装+tomboy
  19. 设置TextBox控件的高度文档翻译
  20. vue学习日记-关于同步跟异步的个人理解

热门文章

  1. 学习OpenCV:滤镜系列(11)——高反差保留 (6.30修改版)
  2. 奇遇张家界 励志湖湘行
  3. 打印问题,需求是跳转到打印页面时直接弹出浏览器打印模式弹窗,当用户点击打印或取消打印时再关掉该打印页面并且返回到目标窗口源(父)页面并重载页面数据
  4. 天使在人间——恩雅个人资料
  5. MySql按条件插入数据,MySQL插入语句写where条件,MySQL在插入时做幂等
  6. 计算机中哪些服务是可以禁止的,win10电脑哪些服务可以关闭?
  7. php restful是什么意思,怎么理解restful
  8. EasyExcel导出动态合并单元格
  9. Unity的新合作伙伴关系为各行各业的开发商带来了经过验证的解决方案
  10. 34 | 别再说不能使用Join了(这是常识问题-上篇)