Timer is Running

Finding Dory
##### Submissions: 352   Accuracy: 51.69%   Difficulty: Basic   Marks: 1

My friend generated a series 1 4 8 9 12 17 25 28 .... . Each element of this series is known as "Dory". Your task is to find out whether a number "K" is Dory or not.

Hint  : One property used to find elements in this series resembles a very famous mathematical series of all time and you can solve this series in O(sqrt(n))

Example :
Input :

The first line of input contains an integer T denoting the Test cases. Then T test cases follow.
Second line contains value of number "K"

Output :
If "K"is "Dory", then Print "1" else print "0"

Constraints :
1 ≤ T ≤ 50
1 ≤ K ≤ 1011

Input :
5
1
12
115
116
117

Output :
1
1
0
1
0

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Mohit Gupta_OMG :)
Author: Mohit Gupta 4

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.