Codeforces Round #748 (Div. 3)的其他题解在这
A. Elections
题目大意:
有三个人进行选举,分别有a, b, c票,问每个人各需要多少票才能成为第一。
思路:
对于每个人,肯定要变得比其他两个人最大值还要大一才行,或者三者唯一最大就是自己本身
所以 每个人的答案就是 max(0, max(其他两人) - 自己 + 1)
AC代码:
#include <bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
using namespace std;
const double eps = 1e-8;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const int INF = 1<<30;
inline void swap(int &x, int &y){x^=y^=x^=y;}
inline int gcd(int a,int b) {return !b ? a : gcd(b,a%b);}
int main(){
int T;
scanf("%d", &T);
while(T--){
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
printf("%d %d %d\n", max(0, max(b, c) - a + 1),
max(0, max(a, c) - b + 1),
max(0, max(a, b) - c + 1));
}
return 0;
}