Summation of Summations
Define the m -fold iterated partial sum of a sequence (a_1, a_2,..., a_n) by S^((m))_n = sum_(i_1=1)^n sum_(i_2=1)^(i_1)... sum_(i_m=1)^i_(m-1) a_(i_m). Find a closed-form expression for S^((m))_n...
Problem Statement
This archive keeps the full statement, math, and original media on the page.
Consider a unit circle \(C_0\) on the plane that does not enclose the origin. For \(k \geq 1\), a circle \(C_k\) is created by scaling and
rotating \(C_{k - 1}\)
It is given that \(C_0\) is externally tangent to \(C_1\), \(C_7\) and \(C_8\), as shown in the diagram belowm, and no two circles overlap.

Find the total area of all the circular triangles in the diagram, i.e. the are painted green above.
Give your answer rounded to \(10\) places after the decimal point.
Problem 894: Summation of Summations
Mathematical Foundation
Theorem 1 (Hockey Stick / Stars-and-Bars Reduction). For any sequence and integers , :
Proof. The element appears in once for each weakly increasing chain . Setting for and for , we obtain nonneg integers with the constraint . More precisely, the chain is equivalent to choosing nonneg integers summing to at most , which by a standard stars-and-bars argument yields
chains.
Theorem 2 (Matrix Formulation). Let be the lower-triangular matrix with . Then , and for .
Proof. We proceed by induction on . For , and . Assuming , we compute
where the last step applies the hockey stick identity .
Lemma (Special Cases).
- For : .
- For : .
Proof. For : by the hockey stick identity.
For : . Using the identity and the absorption identity … Alternatively, note that for , and applying repeatedly, follows by induction using the hockey stick identity.
Editorial
m-fold iterated partial sum: S^(m)_n = sum_k C(n-k+m-1, m-1) * a_k Special case a_k = k: S^(m)_n = C(n+m, m+1). We o(n) computation using Theorem 1. We then compute binomial coefficients incrementally. Finally, update: binom(n-k+m-1, m-1) -> binom(n-(k-1)+m-1, m-1).
Pseudocode
O(n) computation using Theorem 1
Compute binomial coefficients incrementally
Update: binom(n-k+m-1, m-1) -> binom(n-(k-1)+m-1, m-1)
O(mn) computation via m passes of prefix sums
Complexity Analysis
- Time (closed-form method): — single pass with incremental binomial coefficient updates.
- Space (closed-form method): beyond the input array.
- Time (prefix sum method): — passes of prefix summation.
- Space (prefix sum method): for the working array.
- Time (naive nested loops): .
- Space (naive nested loops): .
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
/*
* Problem 894: Summation of Summations
* m-fold iterated partial sum: S^(m)_n = sum_k C(n-k+m-1, m-1) * a_k.
* For a_k = k: S^(m)_n = C(n+m, m+1).
* Three approaches: nested loops O(n^m), prefix sums O(mn), closed form O(n).
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll comb(ll n, ll r) {
if (r < 0 || r > n) return 0;
if (r > n - r) r = n - r;
ll result = 1;
for (ll i = 0; i < r; i++) {
result = result * (n - i) / (i + 1);
}
return result;
}
// Method 1: Direct nested loops for m=3
ll triple_sum_brute(const vector<ll>& a) {
int n = a.size();
ll total = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j <= i; j++)
for (int k = 0; k <= j; k++)
total += a[k];
return total;
}
// Method 2: Prefix sum applied m times
ll iterated_prefix(vector<ll> a, int m) {
int n = a.size();
for (int step = 0; step < m; step++)
for (int i = 1; i < n; i++)
a[i] += a[i - 1];
return a[n - 1];
}
// Method 3: Closed-form weighted sum
ll closed_form(const vector<ll>& a, int m) {
int n = a.size();
ll total = 0;
for (int k = 0; k < n; k++) {
ll weight = comb(n - 1 - k + m - 1, m - 1);
total += weight * a[k];
}
return total;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// Verification: a_k = k, m = 3
cout << "=== Triple Summation (m=3, a_k=k) ===" << endl;
for (int n = 1; n <= 10; n++) {
vector<ll> a(n);
for (int i = 0; i < n; i++) a[i] = i + 1;
ll b = triple_sum_brute(a);
ll p = iterated_prefix(a, 3);
ll c = closed_form(a, 3);
ll identity = comb(n + 3, 4);
cout << "n=" << setw(2) << n
<< ": brute=" << setw(6) << b
<< " prefix=" << setw(6) << p
<< " formula=" << setw(6) << c
<< " C(n+3,4)=" << setw(6) << identity
<< (b == p && p == c && c == identity ? " OK" : " FAIL") << endl;
assert(b == p && p == c && c == identity);
}
// General m verification
cout << "\n=== Various m (a_k=k, n=10) ===" << endl;
int n = 10;
vector<ll> a(n);
for (int i = 0; i < n; i++) a[i] = i + 1;
for (int m = 1; m <= 6; m++) {
ll prefix = iterated_prefix(a, m);
ll formula = closed_form(a, m);
ll identity = comb(n + m, m + 1);
cout << "m=" << m << ": prefix=" << prefix
<< " formula=" << formula
<< " C(n+m,m+1)=" << identity
<< (prefix == formula && formula == identity ? " OK" : " FAIL") << endl;
}
// Large computation
ll ans = comb(10003, 4);
cout << "\nS^(3)_{10000} for a_k=k = C(10003,4) = " << ans << endl;
cout << "\nAnswer: " << ans << endl;
return 0;
}
"""
Problem 894: Summation of Summations
m-fold iterated partial sum: S^(m)_n = sum_k C(n-k+m-1, m-1) * a_k
Special case a_k = k: S^(m)_n = C(n+m, m+1).
"""
from math import comb
def iterated_sum_brute(a, m):
"""Compute m-fold iterated partial sum by nested iteration."""
n = len(a)
current = list(a)
for _ in range(m):
prefix = [0] * n
prefix[0] = current[0]
for i in range(1, n):
prefix[i] = prefix[i - 1] + current[i]
current = prefix
return current[-1]
def iterated_sum_formula(a, m):
"""Compute using closed-form: sum_k C(n-k+m-1, m-1) * a_k."""
n = len(a)
total = 0
for k in range(n):
weight = comb(n - 1 - k + m - 1, m - 1)
total += weight * a[k]
return total
def iterated_sum_prefix(a, m):
"""Compute by applying prefix sum m times. O(mn)."""
current = list(a)
for _ in range(m):
for i in range(1, len(current)):
current[i] += current[i - 1]
return current[-1]
def iterated_sum_identity(n, m):
"""For a_k = k: S^(m)_n = C(n+m, m+1)."""
return comb(n + m, m + 1)
# --- Verification ---
print("=== Triple Summation (m=3) Verification ===")
for n in range(1, 11):
a = list(range(1, n + 1)) # a_k = k
brute = iterated_sum_brute(a, 3)
formula = iterated_sum_formula(a, 3)
prefix = iterated_sum_prefix(a, 3)
identity = iterated_sum_identity(n, 3)
match = "OK" if brute == formula == prefix == identity else "FAIL"
print(f" n={n:>2}: brute={brute:>6}, formula={formula:>6}, "
f"prefix={prefix:>6}, C(n+3,4)={identity:>6} {match}")
assert brute == formula == prefix == identity
print("\n=== a_k = 1 (m=2) ===")
for n in range(1, 11):
a = [1] * n
result = iterated_sum_formula(a, 2)
expected = comb(n + 1, 2)
print(f" n={n}: S^(2) = {result}, C(n+1,2) = {expected}, "
f"Match: {'OK' if result == expected else 'FAIL'}")
assert result == expected
print("\n=== General sequence verification ===")
a = [3, 1, 4, 1, 5, 9, 2, 6]
for m in range(1, 6):
brute = iterated_sum_brute(a, m)
formula = iterated_sum_formula(a, m)
prefix = iterated_sum_prefix(a, m)
print(f" m={m}: brute={brute}, formula={formula}, prefix={prefix}, "
f"Match: {'OK' if brute == formula == prefix else 'FAIL'}")
assert brute == formula == prefix
print("\n=== Weight Table (m=3, n=5) ===")
n = 5
print(f"{'k':>3} {'C(n-k+2,2)':>12} {'Contribution (a_k=k)':>22}")
for k in range(1, n + 1):
w = comb(n - k + 2, 2)
print(f"{k:>3} {w:>12} {w * k:>22}")
# Large computation
n_large = 10000
m_large = 3
a_large = list(range(1, n_large + 1))
result = iterated_sum_identity(n_large, m_large)
print(f"\nS^(3)_{{10000}} for a_k=k: C(10003, 4) = {result}")
answer = result
print(f"\nAnswer: {answer}")
# --- 4-Panel Visualization ---