aboutsummaryrefslogtreecommitdiff
path: root/01_introductory_problems/two_knights_1072.cpp
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-07-06 19:08:08 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2026-07-06 19:08:08 +0200
commit96254947699986c59f0dc63d69fd4b76bd3ed43e (patch)
tree6c4dca945d7f7427c48be234d827fe4d33be02c5 /01_introductory_problems/two_knights_1072.cpp
downloadcses-96254947699986c59f0dc63d69fd4b76bd3ed43e.tar.gz
cses-96254947699986c59f0dc63d69fd4b76bd3ed43e.zip
Initial commit
Diffstat (limited to '01_introductory_problems/two_knights_1072.cpp')
-rw-r--r--01_introductory_problems/two_knights_1072.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/01_introductory_problems/two_knights_1072.cpp b/01_introductory_problems/two_knights_1072.cpp
new file mode 100644
index 0000000..15d5f55
--- /dev/null
+++ b/01_introductory_problems/two_knights_1072.cpp
@@ -0,0 +1,24 @@
1#include <iostream>
2#include <vector>
3
4int main() {
5 long long n, a;
6 std::vector<long long> b = {0, 0, 6, 28, 96};
7 std::cin >> n;
8
9 for (long long k = 1; k <= n; k++) {
10 if (k <= 4) {
11 a = b[k];
12 } else {
13 // Both knights in new strip
14 a += (2*k - 1)*(k - 1) - 2;
15
16 // One knight in new strip, one in previous square
17 const long long s = (k-1)*(k-1);
18 a += 5*(s - 2);
19 a += 4*(s - 3);
20 a += (2*k - 10)*(s - 4);
21 }
22 std::cout << a << std::endl;
23 }
24}

Generated with cgit - Back to sebastiano.tronto.net