Content

已知有三个正整数 \(a,b,c\),现在给出 \(a+b,a+c,b+c,a+b+c\)(不保证有序)的值,试求出 \(a,b,c\)。

数据范围:\(2\leqslant a+b,a+c,b+c,a+b+c\leqslant 10^9\)。

Solution

肯定地,如果是无序的话,那么我们肯定要先对这四个值排序,得到:

\[\begin{cases}x_1=a+b\\x_2=a+c\\x_3=b+c\\x_4=a+b+c\end{cases}
\]

那么,运用加减消元,我们就可以得到:

\[\begin{cases}a=x_4-x_3\\b=x_4-x_2\\c=x_4-x_1\end{cases}
\]

直接输出这三个值就好了。

Code

int x[7];

int main() {
_for(i, 1, 4) getint(x[i]);
sort(x + 1, x + 5);
int a = x[4] - x[1], b = x[4] - x[2], c = x[4] - x[3];
writeint(a), putchar(' '), writeint(b), putchar(' '), writeint(c);
return 0;
}

CF1154A Restoring Three Numbers 题解的更多相关文章

  1. 题解【CodeForces1154A】Restoring Three Numbers

    Description Polycarp has guessed three positive integers \(a\), \(b\) and \(c\). He keeps these numb ...

  2. CF55D Beautiful numbers 题解

    题目 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer n ...

  3. Hdoj 1905.Pseudoprime numbers 题解

    Problem Description Fermat's theorem states that for any prime number p and for any integer a > 1 ...

  4. Hdoj 1058.Humble Numbers 题解

    Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...

  5. [LeetCode] Add Two Numbers题解

    Add Two Numbers: You are given two non-empty linked lists representing two non-negative integers. Th ...

  6. poj 1995 Raising Modulo Numbers 题解

    Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6347   Accepted: ...

  7. CF1265B Beautiful Numbers 题解

    Content 给定一个 \(1\sim n\) 的排列,请求出对于 \(1\leqslant m\leqslant n\),是否存在一个区间满足这个区间是一个 \(1\sim m\) 的排列. 数据 ...

  8. CF1157A-Reachable Numbers题解

    原题地址 题目大意:有一个函数\(f(x)\),效果是将\(x+1\)后,去掉末尾所有的\(0\),例如: \(f(599)=6\),因为\(599+1=600→60→6\) \(f(7)=8\),因 ...

  9. CF359D:Pair of Numbers——题解

    https://vjudge.net/problem/CodeForces-359D http://codeforces.com/problemset/problem/359/D 题目大意: 给一串数 ...

随机推荐

  1. 深入了解SpringMVC源码解析

    Spring MVC源码解析 Spring MVC的使用原理其实是通过配置一个Servlet来接管所有的请求,所有的请求由这个Servlet来进行分发处理. 我们可以从web.xml里面看出这一点 & ...

  2. Python+selenium之多窗口,句柄

  3. 使用protobuf-java-format包 JsonFormat转Json部分默认值字段消失问题

    使用protobuf-java-format包 JsonFormat转Json部分默认值字段消失问题 1.产生的bug XXXXXXXXRequest.Builder request = XXXXXX ...

  4. Codeforces 1270E - Divide Points(构造+奇偶性)

    Codeforces 题目传送门 & 洛谷题目传送门 显然,直接暴力枚举是不可能的. 考虑将点按横纵坐标奇偶性分组,记 \(S_{i,j}=\{t|x_t\equiv i\pmod{2},y_ ...

  5. DAS,NAS,SAN,简介

    根据服务器类型分为:封闭系统的存储和开放系统的存储,封闭系统主要指大型机,开放系统指基于Windows.UNIX.Linux等操作系统的服务器;开放系统的存储分为:内置存储和外挂存储;外挂存储根据连接 ...

  6. Linux学习——Gdb基本调试方法&&多线程调试

    1.Gdb的基本调试 示例代码 //e.c #include <stdio.h> void debug(char *str) { printf("debug info :%s\n ...

  7. Linux文件系统属性和权限概念详解(包含inode、block、文件权限、文件软硬链接等)

    Linux中的文件属性 ls -lih 包括:索引节点(inode),文件类型,权限属性,硬链接数,所归属的用户和用户组,文件大小,最近修改时间,文件名等等 索引节点:相当于身份证号,系统唯一,系统读 ...

  8. C#序号

    OnRowCreated="gridViewCorrection_RowCreated" <asp:BoundField HeaderText="序号" ...

  9. HTML5 之 FileReader 的使用 (二) (网页上图片拖拽并且预显示可在这里学到) [转载]

    转载至 : http://www.360doc.com/content/14/0214/18/1457948_352511645.shtml FileReader 资料(英文): https://de ...

  10. Linux学习 - 流程控制

    一.if语句 1 单分支if条件语句 (1) if  [ 条件判断式 ];then 程序  fi (2) if [ 条件判断式 ] then 程序  fi 例:检测根分区的使用量 2 双分支if条件语 ...