A. Dislike of Threes
B. Who's Opposite?
#include<bits/stdc++.h>
using namespace std;
int t, a, b, c;
int main() {
cin >> t;
for(int i = 1; i <= t; i++) {
cin >> a >> b >> c;
int d = max(a, b) - min(a, b);
if(a > 2 * d || b > 2 * d || c > 2 * d) cout << "-1" << endl;
else if(c > d && c <= d * 2) cout << c - d << endl;
else if (c + d <= d * 2) cout << c + d << endl;
else cout << "-1" << endl;
}
return 0;
}
C. Infinity Table
#include<bits/stdc++.h>
using namespace std;
int t, k;
void deal(int x) {
int i;
for(i = 1; i <= 100000; i++)
if(i * i >= x) break;
int tmp = i * i;
int temp = i * i - i + 1;
if(x >= temp) cout << i << " " << tmp - x + 1 << endl;
else cout << i - temp + x << " " << i << endl;
}
int main() {
cin >> t;
for(int i = 1; i <= t; i++) {
cin >> k;
deal(k);
}
return 0;
}