L 清楚姐姐的三角形I【2023牛客寒假算法基础集训营4】

L 清楚姐姐的三角形I

原题链接

代码

点击查看代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;

#define X first
#define Y second

typedef long long LL;
const char nl = '\n';
const int N = 1e6+10;
int n,m;

void solve(){
	LL va,vb,vc;
	cin >> va >> vb >> vc;
	LL a,b,c;
	c = (va+vb-vc)/2;
	b = (va+vc-vb)/2;
	a = (vb+vc-va)/2;
	if(a+b<=c||a+c<=b||b+c<=a||a<=0||b<=0||c<=0)cout<< "No" << nl;
	else{
		cout << "Yes" << nl;
		cout << a << " " << b << " " << c << nl;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);

	int T;
	cin >> T;
	while(T --){
		solve();
	}
	//solve();
}

注意

  1. 判断是否是三角形(最大边小于其余两边之和,三边都是正数)
  2. 给出的\(v_a,v_b,v_c\)不一定满足题设条件
posted @ 2023-01-31 20:32  Keith-  阅读(22)  评论(0编辑  收藏  举报