Believer
Time limit2sMemory limit512 MB
For each n up to 1e18, find the maximum over all positive-integer sequences summing to n of the total popcount of the multiplicities of the distinct values.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Greedy, Math, Bit manipulation
- Solved
- No attempts yet
Problem
Do you believe in dragons? Imagine one of them wakes you up at night and asks the following.
Consider sequences of positive integers .
Let be the number of occurrences of in . For example, .
Let be the number of ones in the binary expansion of . For example, .
Let . For example, .
For the given value of , find the maximum value of over all sequences with .
What would you answer?
Input
The first line contains a single integer ().
Each of the next lines contains a single integer ().
Output
For each test case, in the order of the input, print a single integer on its own line: the answer to the problem.
Notes
In the first example, one sequence with is .