-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIP_6.cpp
66 lines (64 loc) · 1.22 KB
/
IP_6.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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve(ll int x, ll int y)
{
if(x == y)
{
if(x % 2 == 0)
{
cout << x*x - y + 1 ;
cout << "\n";
return ;
}
else
{
cout << y*y - x + 1 ;
cout << "\n";
return ;
}
}
else if(y > x)
{
if(y % 2 == 0)
{
cout << (y-1)*(y-1) + x ;
cout << "\n";
return ;
}
else
{
cout << y*y - x + 1 ;
cout << "\n";
return ;
}
}
else
{
if(x % 2 == 0)
{
cout << x*x - y + 1 ;
cout << "\n";
return ;
}
else
{
cout << (x-1)*(x-1) + y ;
cout << "\n";
return ;
}
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll int tc = 1;
cin >> tc;
for (ll int t = 1; t <= tc; t++) {
// cout << "Case #" << t << ": ";
ll int x, y;
cin >> x;
cin >> y;
solve(x, y);
}
}