Maximum Value
Time limit5sMemory limit128 MB
Given bounds and a fixed sum constraint on real numbers, compute the maximum possible sum of their p-th powers using a convexity-based extremal argument.
- Level
Hard8 of 10
- Topics
- Math, Greedy, Combinatorics
- Solved
- No attempts yet
Problem
Let be real numbers that, for some integers and with , satisfy the following conditions:
- for every ;
- .
Given an even positive integer , write a program that finds the maximum possible value of .
Input
The first line contains the number of test cases . Each test case consists of a single line containing , , , and (, , and is even).
Only inputs for which real numbers satisfying the conditions exist are given.
Output
For each test case, print on its own line the maximum value of the expression, rounded to the nearest integer (rounded at the first digit after the decimal point).