Problem

Submissions

2

Avg. time to solve

15 min

Success Rate

80%

Problem Statement

```
N = 21
The perfect square closest to 21 is 25, and the distance is 4.
```

```
The first line contains a single integer ‘T’ denoting the number of test cases to be run. Then the test cases follow.
The first line of each test case contains a positive integer ‘N’ denoting the given number.
```

```
For each test case, You have to return a list of two integers such that the first number denotes the closest perfect square number, and the second number denotes its distance from ‘N’.
Output for each test case will be printed in a separate line.
```

```
You are not required to print anything; it has already been taken care of. Just implement the function.
```

```
1 <= T <= 50
1 <= N <= 10^9
Time Limit: 1 sec.
```

```
2
21
5
```

```
25 4
4 1
```

```
For test case one-
25 is the perfect square nearest to 21 and at a distance of 4.
For test case two-
4 is the perfect square nearest to 5 and at a distance of 1.
```

```
2
132
146
```

```
121 11
144 2
```

Console