-
Notifications
You must be signed in to change notification settings - Fork 3
/
A_Distance.cpp
111 lines (95 loc) · 1.85 KB
/
A_Distance.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <bits/stdc++.h>
#define ll long long
#define ld long int
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
using namespace std;
// 8""""8
// 8 " eeeee eeeee eeee
// 8e 8 88 8 8 8
// 88 8 8 8e 8 8eee
// 88 e 8 8 88 8 88
// 88eee8 8eee8 88ee8 88ee
// --------MATHS OPERATIONS---------
const int N = 2e5 + 1;
const int MOD = 1e9 + 7;
ll fact[N], inv[N], invfact[N];
void factInverse()
{
fact[0] = inv[1] = fact[1] = invfact[0] = invfact[1] = 1;
for (long long i = 2; i < N; i++)
{
fact[i] = (fact[i - 1] * i) % MOD;
inv[i] = MOD - (inv[MOD % i] * (MOD / i) % MOD);
invfact[i] = (inv[i] * invfact[i - 1]) % MOD;
}
}
int add(int a, int b)
{
if ((a += b) >= MOD)
a -= MOD;
else if (a < 0)
a += MOD;
return a;
}
ll mul(int x, int y)
{
return (1LL * x * y) % MOD;
}
ll nCr(int n, int r)
{
if (r > n)
return 0;
return mul(mul(fact[n], invfact[r]), invfact[n - r]);
}
long long pow(long long base, long long n, long long m = MOD)
{
long long ans = 1ll;
while (n != 0)
{
if (n % 2)
{
ans = (ans * base) % m;
n--;
}
else
{
base = (base * base) % m;
n /= 2;
}
}
return ans;
}
// --------SOLVE---------
void solve()
{
int x, y;
cin >> x >> y;
int sum = x + y;
if (sum & 1)
{
cout << "-1 -1" << endl;
}
else
{
int to_reduce = sum /= 2;
int sub_x = min(x, to_reduce);
to_reduce -= sub_x;
int sub_y = min(y, to_reduce);
cout << x - sub_x << " " << y - sub_y << endl;
}
}
// --------XXXXXXXXX---------
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while (t--)
{
solve();
}
return 0;
}