From 96254947699986c59f0dc63d69fd4b76bd3ed43e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 6 Jul 2026 19:08:08 +0200 Subject: Initial commit --- 01_introductory_problems/two_knights_1072.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 01_introductory_problems/two_knights_1072.cpp (limited to '01_introductory_problems/two_knights_1072.cpp') 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 @@ +#include +#include + +int main() { + long long n, a; + std::vector b = {0, 0, 6, 28, 96}; + std::cin >> n; + + for (long long k = 1; k <= n; k++) { + if (k <= 4) { + a = b[k]; + } else { + // Both knights in new strip + a += (2*k - 1)*(k - 1) - 2; + + // One knight in new strip, one in previous square + const long long s = (k-1)*(k-1); + a += 5*(s - 2); + a += 4*(s - 3); + a += (2*k - 10)*(s - 4); + } + std::cout << a << std::endl; + } +} -- cgit v1.3