## ARCTAN Statement

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.

## ARCTAN Solution

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include <iostream> #include <cmath> using namespace std; int T, N; int main() { cin >> T; while (T --) { cin >> N; long long top = 1LL * N * N + 1; long long root = (int)(1. * top); while (top % root) root --; cout << N + N + top / root + root << endl; } return 0; } |

**You also like to see:**