Straight Question

3.6

8 votes
Easy-Medium
Problem

Tired of reading long questions. Here comes a straight one for you.

Find the expected value of the side length of a randomly chosen square in a matrix of size n*n.

Input:
The first line contains an integer t (number of test cases).
Following t lines contain a number n each.

Output:
Print the floor value of the expected value in a new line for each test case.

Constraints:
1 ≤ t ≤ 100000
1≤ n ≤ 10^18

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

n=3

enter image description here


Here, we have 9 squares of side length 1.
4 squares of side length 2
1 square of side length 3
Total number of squares are 9+4+1=14
So, expected value of side length= 1 * 9/14 + 2 * 4/14 + 3 * 1/14=(1 * 9 + 2 * 4 + 3 * 1) / 14 = 20 / 14=1.428571

Editor Image

?