This page is still under construction.

Parts of this page are still being built. What you see may change.

Combine The Gears

Time limit2sMemory limit256 MB

Summary
Given a budget b, choose gear sizes with total cost at most b to maximize the number of distinct pointer-direction tuples, output as a natural logarithm.
Level

Hard8 of 10

Topics
Math, Number theory, Greedy, Dynamic programming
Solved
No attempts yet

Problem

As society develops quickly, the demand for high-precision clocks keeps rising. Recently, the China Clock Production Company has been developing a new type of clock that can represent a wide range of times.

This novel clock displays the current time in an unusual way. The clock consists of several pointers, each controlled by one gear. All gears rotate in sync, advancing one tooth per period. The gears may have different numbers of teeth, though. If a gear has tt teeth, the pointer it controls can point in tt different directions, denoted 0,1,2,⋯ ,t−10, 1, 2, \cdots, t-1, where 00 is the initial direction. Moreover, if a clock has nn pointers and the ii-th pointer is controlled by a gear with t_it\_i teeth, then after kk periods the ii-th pointer points to k mod t_ik \bmod t\_i.

A gear with tt teeth costs tt yuan. Given a total budget of bb yuan, you must design a combination of gears that maximizes the number of valid combinations of pointer directions, while the total cost of the gears does not exceed the budget. A combination of directions (d_1,d_2,⋯ ,d_n)(d\_1, d\_2, \cdots, d\_n) is valid if it can be written as (k mod t_1,k mod t_2,⋯ ,k mod t_n)(k \bmod t\_1, k \bmod t\_2, \cdots, k \bmod t\_n) for some nonnegative integer kk, where t_it\_i is the number of teeth of the ii-th gear. Since the answer may be too large, output it as a natural logarithm (logarithm with base e=2.718281828⋯e = 2.718281828\cdots).

Input

The first line of input contains a single integer TT (1≤T≤30  000)(1 \leq T \leq 30\;000), the number of test cases. Each test case is a single line containing an integer bb (1≤b≤30  000)(1 \leq b \leq 30\;000), the total budget.

Output

For each test case, print on a single line the natural logarithm of the maximum number of valid combinations, with an absolute or relative error of no more than 10−610^{-6}.

Hint

For the second sample case, a 3-tooth gear together with a 4-tooth gear yields 12 different combinations of directions, and the total cost is exactly 7. So you should print the value of ln⁡12\ln 12, which is approximately 2.484906650.

Examples1

  1. Example 1

    Input
    3
    2
    7
    10
    
    Expected output
    0.693147181
    2.484906650
    3.401197382