A. Three Pairwise Maximums
解题思路
- 因为
x
=
m
a
x
(
a
,
b
)
,
y
=
m
a
x
(
a
,
c
)
x=max(a,b),y=max(a,c)
x=max(a,b),y=max(a,c)且
z
=
m
a
x
(
b
,
c
)
z=max(b,c)
z=max(b,c),我们可以得出
x
,
y
,
z
x,y,z
x,y,z中至少有两个数是相等的,且一定大于等于另一个数
- 如果
x==y则说明
a
a
a为最大值,此时需要满足a>=z,如果不满足该条件,则无解,因为
z
=
m
a
x
(
b
,
c
)
z=max(b,c)
z=max(b,c),我们不能确定
b
,
c
b,c
b,c谁比较大,所以我们就假设两个数一样的即可。 - 记住输出时不能输出
b
,
c
b,c
b,c为
z
z
z和
z
−
1
z-1
z−1,因为
a
,
b
,
c
a,b,c
a,b,c需要是正整数,如果
z
=
1
z=1
z=1,此时的
z
−
1
z-1
z−1是不满足条件的
x==z时和y==z时同理- 具体操作见代码
附上代码
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double PI=acos(-1.0);
const double e=exp(1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=2e5+10;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--){
int a=0,b=0,c=0,x,y,z;
cin>>x>>y>>z;
if(x==y) a=x;
else if(y==z) c=y;
else if(x==z) b=x;
if((a&&a>=z)||(b&&b>=y)||(c&&c>=x)){
cout<<"YES"<<endl;
if(a) cout<<a<<" "<<z<<" "<<z<<endl;
else if(b) cout<<b<<" "<<y<<" "<<y<<endl;
else if(c) cout<<c<<" "<<x<<" "<<x<<endl;
}
else
cout<<"NO"<<endl;
}
return 0;
}