/ OPS / 题库 /

Convert Kilometers to Miles

Convert Kilometers to Miles

#描述#
This year, Bruce Force spends his vacation in Flagstaff, Arizona, where he wants to practice for his next half marathon (a race over 21 km). At his first training he runs to his friend Greedy Gonzales' home which is 21 miles away from Flagstaff.<br><br>Arriving there, he is very tired and realizes that 21 miles are much more than 21 km. Greedy Gonzales tells him that 21 km equals 13 miles. 21, 13? Bruce realizes immediately that there must be a deeper relation! Both, 13 and 21 are Fibonacci numbers!<br><br>Fibonacci numbers can be defined as follows:<br>F[1] = 1<br>F[2] = 2<br>F[n+1] = F[n]+F[n-1] for n>1<br><br>Bruce has just learned about the Fibonacci number system at his university. Each positive integer x can be written as the sum of different Fibonacci numbers, so this means that there exists numbers k and b[1], b[2], ..., b[k] such that x = ∑ b[i] * Fi, where b[k] = 1 and bi is either 0 or 1. In short, we can write the representation as: b(x) = (b[k], b[k-1], ..., b[1]). To make the representation unique, we require that b[i] * b[i-1] = 0 for all i > 1.<br><br>For example 21 can be represented as (1,0,0,0,0,0,0) and 13 as (1,0,0,0,0,0) in the Fibonacci system. Bruce notices that one can convert a distance x in kilometers into a corresponding distance y to miles as follows: First, write down x in its Fibonacci system representation b(x). Second, shift the bits of b(x) one position to the right (the last bit is deleted) and get b(y). Third, calculate y from b(y) by evaluating the sum given above.<br><br>For example, the number 42 written in the Fibonacci system is (1,0,0,1,0,0,0,0). In step two we would shift the bits one position to the right and get (1,0,0,1,0,0,0). In the third step, we would calculate 0*1 + 0*2 + 0*3 + 1*5 + 0*8 + 0*13 + 1*21 = 26.<br><br>Now it's your turn to write a program for Bruce that converts kilometers into miles according to Bruce's algorithm.

#格式#
##输入格式##
The first line of the input contains t, the number of distances Bruce wants to convert from kilometers to miles (0&ltt&lt25000). Each of the next t lines contains an integer distance x (2 &lt x &lt 25000) in kilometers.

##输出格式##
For each distance x in kilometers output the distance y in miles calculated according to Bruce's algorithm.

#样例1#
##样例输入1##

5
42
100
180
300
360

##样例输出1##

26
62
111
185
222

#限制#
1000ms
65536KB

#提示#

#来源#

信息

ID
1558
难度
5
分类
category1 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者