Codeforces Round #577 (Div. 2)A.Fence

A. Fence
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He’s already got three straight fence segments with known lengths a, b, and c. Now he needs to find out some possible integer length d of the fourth straight fence segment so that he can build the fence using these four segments. In other words, the fence should have a quadrilateral shape with side lengths equal to a, b, c, and d. Help Yura, find any possible length of the fourth side.

A non-degenerate simple quadrilateral is such a quadrilateral that no three of its corners lie on the same line, and it does not cross itself.

Input
The first line contains a single integer t — the number of test cases (1≤t≤1000). The next t lines describe the test cases.

Each line contains three integers a, b, and c — the lengths of the three fence segments (1≤a,b,c≤109).

Output
For each test case print a single integer d — the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists.

Example
inputCopy
2
1 2 3
12 34 56
outputCopy
4
42
Note
We can build a quadrilateral with sides 1, 2, 3, 4.

We can build a quadrilateral with sides 12, 34, 56, 42.

题意

给你三条边,让你给出另外一条边使得这四条边能够构成四边形

思路

类比三角形,任意三边之和要大于第四边,所以输出三边和-1即可

注意

边长范围为10e9,使用long long 避免爆数据

#include <stdio.h>
int main(void) {
	int t;
	scanf("%d",&t);
	while(t--) {
		long long ans=0;
		for(int i=0;i<3;i++) {
			int temp;
			scanf("%d",&temp);
			ans+=temp;
		}
		printf("%lld\n",ans-1);
	}
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ljw0925

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值