From 7efb7133f679fcb3399279c3fbf341ad2a737ead Mon Sep 17 00:00:00 2001 From: dm1sh Date: Sun, 31 Oct 2021 16:27:27 +0300 Subject: [PATCH] Changed test generation function --- input.py | 16 +++++++++++++++- run.sh => test.sh | 0 2 files changed, 15 insertions(+), 1 deletion(-) rename run.sh => test.sh (100%) diff --git a/input.py b/input.py index 699f4a9..0f7df10 100644 --- a/input.py +++ b/input.py @@ -7,5 +7,19 @@ except: print(n) +def f(x: int) -> int: + """ + f(x) = sum with i from 0 to n-1 (i+1)*x^i + + E.g. f(x) = 5x^4 + 4x^3 + 3x^2 + 2x + 1 + """ + + res: int = 0 + + for i in range(n): + res += (i+1) * pow(x, i) + + return res + for i in range(n): - print(i, -i if i % 2 == 0 else i) \ No newline at end of file + print(i, f(i)) diff --git a/run.sh b/test.sh similarity index 100% rename from run.sh rename to test.sh