CF1154A Restoring Three Numbers 题解
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
肯定地,如果是无序的话,那么我们肯定要先对这四个值排序,得到:
\]
那么,运用加减消元,我们就可以得到:
\]
直接输出这三个值就好了。
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 题解的更多相关文章
- 题解【CodeForces1154A】Restoring Three Numbers
Description Polycarp has guessed three positive integers \(a\), \(b\) and \(c\). He keeps these numb ...
- CF55D Beautiful numbers 题解
题目 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer n ...
- Hdoj 1905.Pseudoprime numbers 题解
Problem Description Fermat's theorem states that for any prime number p and for any integer a > 1 ...
- Hdoj 1058.Humble Numbers 题解
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...
- [LeetCode] Add Two Numbers题解
Add Two Numbers: You are given two non-empty linked lists representing two non-negative integers. Th ...
- poj 1995 Raising Modulo Numbers 题解
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6347 Accepted: ...
- CF1265B Beautiful Numbers 题解
Content 给定一个 \(1\sim n\) 的排列,请求出对于 \(1\leqslant m\leqslant n\),是否存在一个区间满足这个区间是一个 \(1\sim m\) 的排列. 数据 ...
- CF1157A-Reachable Numbers题解
原题地址 题目大意:有一个函数\(f(x)\),效果是将\(x+1\)后,去掉末尾所有的\(0\),例如: \(f(599)=6\),因为\(599+1=600→60→6\) \(f(7)=8\),因 ...
- CF359D:Pair of Numbers——题解
https://vjudge.net/problem/CodeForces-359D http://codeforces.com/problemset/problem/359/D 题目大意: 给一串数 ...
随机推荐
- PIC16 bootloader之UART bootloader
了解更多关于bootloader 的C语言实现,请加我Q扣: 1273623966 (验证信息请填 bootloader),欢迎咨询或定制bootloader(在线升级程序). PIC16 bootl ...
- JavaSE复习巩固
第二天:复习if语句,扫描器,switch语句,循环语句 1.if语句---流程控制语句 if之前学的语句是顺序结构 1.1 单个if的语法结构 if(条件判断){ 满足条件需要做的事情: } int ...
- 【2020五校联考NOIP #3】序列
题面传送门 原题题号:Codeforces Gym 101821B 题意: 给出一个排列 \(p\),要你找出一个最长上升子序列(LIS)和一个最长下降子序列(LDS),满足它们没有公共元素.或告知无 ...
- Codeforces 1411G - No Game No Life(博弈论+生成函数+FWTxor)
Codeforces 题面传送门 & 洛谷题面传送门 一道肥肠套路的题目. 首先这题涉及博弈论.注意到这里每一个棋子的移动方式都是独立的,因此可以考虑 SG 定理.具体来说,我们先求出每个棋子 ...
- Codeforces 536D - Tavas in Kansas(dp)
Codeforces 题目传送门 & 洛谷题目传送门 其实这题本该 2019 年 12 月就 AC 的(详情请见 ycx 发此题题解的时间),然鹅鸽到了现在-- 首先以 \(s,t\) 分别为 ...
- Codeforces Round #732 (Div.1) 题解
实在是打击人信心的一场比赛啊--一不注意就掉了 50+ 分,rating 没了啊/ll/dk/wq/kk A Weak pretest!!!!!11 /fn/fn/fn 一个很显然的注意点是在交换前后 ...
- 洛谷 P5644 - [PKUWC2018]猎人杀(分治+NTT)
题面传送门 很久之前(2020 年)就听说过这题了,这么经典的题怎么能只听说而亲自做一遍呢 首先注意到每次开枪打死一个猎人之后,打死其他猎人概率的分母就会发生变化,这将使我们维护起来非常棘手,因此我们 ...
- 洛谷 P6860 - 象棋与马(找性质+杜教筛)
题面传送门 首先我们来探究一下什么样的 \((a,b)\) 满足 \(p(a,b)=1\).不难发现只要点 \((1,0)\) 能够到达,那么网格上所有点都能到达,因为由于 \((1,0)\) 能够到 ...
- 1D RKDG to shallow water equations
RKDG to shallow water equations 1.Governing Equations \[\frac{\partial U}{\partial t} + \frac{\parti ...
- python故障
问题: ImportError: No module named dns.resolver 解决: 通过包管理工具pip安装dnspython pip install dnspython