#P17264. [ICPC 2017 Urumqi R] Gathering

[ICPC 2017 Urumqi R] Gathering

Problem Description

In the game of Starcraft, Terran has 11 idle base, 44 idle workers, 66 supplies and 5050 minerals at the beginning. When a worker is idle, the worker can choose one of the following 33 things to do.

  • Gathering minerals: It will cost nothing, and the worker will be busy for 1010 seconds. After that, the minerals will increase by 88 and the worker will be idle again.
  • Building a supply depot: It will cost 100100 minerals immediately, and the worker will be busy for 3030 seconds. After that, the supplies will increase by 88 and the worker will be idle again.
  • Building a base: It will cost 400400 minerals immediately, and the worker will be busy for 120120 seconds. After that, a new idle base will be created, and the supplies will increase by 1010, and the worker will be idle again.

When a base is idle, it can cost 5050 minerals and 11 supply immediately, and it will be busy for 2020 seconds. After that, an idle worker will be created and the base will be idle again.

The amount of minerals and supplies cannot be negative all the time. That is, we must have enough minerals and supplies to be cost before doing anything.

Your task is to reach mm minerals as soon as possible.

Input Format

The first line is the number of test cases which is up to 5252.

For each test case, there is a line containing only 1 integer m(m<264)m (m < 2^{64}).

Output Format

For each test case, output the minimum time to reach mm minerals.

3
100
1000
10000
20
200
640