Maximising a Weighted Product
Let S_m = {(x_1, x_2,..., x_m): x_i > 0, sum_(i=1)^m x_i = m}. Let P_m = max_(S_m) prod_(i=1)^m x_i^i. Find sum_(m=2)^15 floor(P_m).
Problem Statement
This archive keeps the full statement, math, and original media on the page.
Let \(S_m = (x_1, x_2, \dots , x_m)\) be the \(m\)-tuple of positive real numbers with \(x_1 + x_2 + \cdots + x_m = m\) for which \(P_m = x_1 \cdot x_2^2 \cdot \cdots \cdot x_m^m\) is maximised.
For example, it can be verified that \(\lfloor P_{10}\rfloor = 4112\) (\(\lfloor \, \rfloor \) is the integer part function).
Find \(\sum \limits _{m = 2}^{15} \lfloor P_m \rfloor \).
Problem 190: Maximising a Weighted Product
Mathematical Analysis
Optimization via Lagrange Multipliers
We want to maximize subject to .
Taking logarithms, we equivalently maximize:
Using Lagrange multipliers: , which gives:
Therefore: .
Solving for
From the constraint :
Optimal Values
Maximum Value
Proof of Maximum
The log of the objective, , is a concave function on the positive orthant (since each is concave). The constraint is linear. Therefore, any critical point of the Lagrangian is a global maximum. Since we found a unique critical point, it must be the global maximum.
Computation
For each from 2 to 15:
- Compute .
- Compute .
- Take .
- Sum all values.
Correctness
Theorem. The method described above computes exactly the quantity requested in the problem statement.
Proof. The preceding analysis identifies the admissible objects and derives the formula, recurrence, or exhaustive search carried out by the algorithm. The computation evaluates exactly that specification, so every valid contribution is included once and no invalid contribution is counted. Therefore the returned value is the required answer.
Complexity
- Time: , negligible.
- Space: .
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
int main() {
long long total = 0;
for (int m = 2; m <= 15; m++) {
// x_i = 2i / (m+1)
// P_m = product of (2i/(m+1))^i for i=1..m
double log_pm = 0.0;
for (int i = 1; i <= m; i++) {
log_pm += i * log(2.0 * i / (m + 1));
}
long long pm = (long long)floor(exp(log_pm));
total += pm;
}
cout << total << endl;
return 0;
}
"""
Problem 190: Maximising a Weighted Product
For m from 2 to 15, find the maximum of prod(x_i^i) subject to sum(x_i) = m,
then sum floor of each maximum.
"""
import math
from decimal import Decimal, getcontext
def solve():
getcontext().prec = 50
total = 0
for m in range(2, 16):
# Optimal: x_i = 2i / (m+1)
# P_m = product of (2i/(m+1))^i
log_pm = Decimal(0)
for i in range(1, m + 1):
xi = Decimal(2 * i) / Decimal(m + 1)
log_pm += i * xi.ln()
pm = log_pm.exp()
total += int(pm)
print(total)
if __name__ == "__main__":
solve()