ARCTAN - Use of Function Arctan

It's easy to know that arctan(1/2) + arctan(1/3) = arctan(1). Given number A, write a program to calculate the minimum sum B+C. A, B and C are all positive integers and satisfy the equation below:

arctan(1/A) = arctan(1/B) + arctan(1/C)

Input

The first line contains a integer number T (about 1000). T lines follow, each contains a single integer A, 1<=A<=60000.

Output

T lines, each contains a single integer which denotes to the minimum sum B+C.

Example

Sample input:
1
1

Sample output:
5

Added some new test data.


Added by:Fudan University Problem Setters
Date:2007-03-31
Time limit:2s
Source limit:256B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: C99 ERL GOSU JS-RHINO OBJC
Resource:Chinese National Olympiad in Informatics 2001,Day 1; translated by Blue Mary

hide comments
2019-05-30 17:09:22
Calculus?
2018-10-03 14:17:51
No one did it on Python. always time exeeded
2017-10-17 20:28:52
how can i make this below 256b????????


Last edit: 2017-10-21 12:44:38
2014-09-11 15:25:13 albertg
nice problem
2013-05-23 10:52:38 ওয়াসী (Wasi)
tricky one!
at last managed to solve under 256 bytes... :D
2013-01-30 09:02:30 Himanshu
i dont know why it gives WA???
2013-01-15 17:18:08 saket diwakar
nice and tricky....:)
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.