-
Notifications
You must be signed in to change notification settings - Fork 0
/
Two_Knights.cpp
78 lines (61 loc) · 1.14 KB
/
Two_Knights.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
#include <bits/stdc++.h>
using namespace std;
long long ss(int a)
{
if (a < 1)
return 0;
long long res = 1;
for (int i = 0; i < 8 * sizeof(int); i++)
{
long long cur = 1 << i;
if (cur > a)
break;
res = cur;
}
return res;
}
void solve()
{
long long a, b;
cin >> a >> b;
long long res = 0;
res += max(a - 1, b - 1) * max(a - 1, b - 1);
long long mx = max(a - 1, b - 1);
if (mx % 2 == 0)
{
if (mx == a - 1)
{
res = mx * mx + b;
}
else
{
res = (mx + 1) * (mx + 1) - (a - 1);
}
}
else
{
if (mx == a - 1)
{
res = (mx + 1) * (mx + 1) - (b - 1);
}
else
{
res = (mx * mx) + a;
}
}
cout << res << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (unsigned long long i = 1; i <= n; i++)
{
unsigned long long res = (((i * i) * (i * i - 1)) / 2) - (4 * (i - 1) * (i - 2));
cout << res << '\n';
}
return 0;
}