Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
clarify solution
Browse files Browse the repository at this point in the history
  • Loading branch information
glacialcascade committed Jun 9, 2024
1 parent 55d67e3 commit 8656485
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions snail-farmer-john/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@

fin = open("input.txt", "r")
fout = open("fast.out", "w")

# Read the input
(n, k) = [int(x) for x in fin.readline().split(" ")]
arr = [int(x) for x in fin.readline().split(" ")]
assert len(arr) == k

sum = sum(arr)

start = sum + n - k + 1
out = 0
for i in range(start, sum, -3):
out += (i * (i - 1) * (i - 2) * (i - 3)) // 8
for i in range(n, k-1, -3):
num = sum + i - k # add i-k for the extra 1s at the end
out += ((num+1) * (num) * (num - 1) * (num - 2)) // 8
fout.write("bcactf{" + str(out) + "}")

0 comments on commit 8656485

Please sign in to comment.