Sphere Online Judge

SPOJ Problem Set (classical)

1440. Use of Function Arctan

Problem code: ARCTAN

It's easy to know that arctan(1/2)+arctan(1/3)=arctan(1).The problem is,to some fixed number A,you have to 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.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

Some new test data has been added on Feb.15, 2009, 36 users lose their Accepted.


Added by:[Trichromatic] XilinX
Date:2007-03-31
Time limit:10s
Source limit:256B
Languages:All except: C99 strict ERL TECS JS
Resource:Chinese National Olympiad in Informatics 2001,Day 1; translated by Blue Mary

hide comments
2009-05-19 16:44:50 Frank Rodriguez
What is the upper bound of T?
EDIT: Nevermind, it seems to be small enough.

Last edit: 2009-05-22 16:18:30
SPOJ System © 2008-2010 Sphere Research Labs. All Rights Reserved.