Dom is a Prime

3

1 votes
Problem

Dominic has left his family and gone in the dark. He did it to protect his family. Sources say that he is busy in his research on prime numbers these days. People have build stories of his adventure. Some say that while roaming on the streets of Miami he saw numbers written on the street in a spiral and he observed that many prime numbers occur on both the diagonals as shown in figure below (You don't doubt his brilliant observation skills, do you?).

37 36 35 34 33 32 31
38 17 16 15 14 13 30
39 18  5  4  3 12 29
40 19  6  1  2 11 28
41 20  7  8  9 10 27
42 21 22 23 24 25 26
43 44 45 46 47 48 49

We know Dom. He cannot let any street junkie outsmart him. And so he is trying to know what percentage of prime numbers are there on both the diagonals to that to all the numbers on the diagonal. Now you know he won't directly ask you for your help but this is your chance to get his attention and be a part of the family. Show him how smart you are by writing a code to help him with this task.

NOTE: N is always an odd number.

Input: First line of input contains an integer t, which is the number of test cases. t lines follow, with each test containing an integer, N, which is the size of spiral matrix.

Output: For each test case output a single line which is the percentage of number of prime numbers on the diagonal to the total numbers on diagonal, correct to six decimal places.

Constraints :
1<= t <=10^5
3 <= N <= 10^4

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

The above spiral represents the spiral of size 7.
Numbers on the diagonal are: 37, 17, 5 ,1, 9, 25, 49, 31, 13, 3 ,7, 21, 43
Out of which prime numbers are: 37, 17, 5, 31, 13, 3, 7, 43

61.538462% of total numbers on diagonal are prime numbers.

Editor Image

?