Kaprekar Number
Submissions: 1033   Accuracy:

22.42%

  Difficulty: Easy   Marks: 2

A Kaprekar number is a number whose square when divided into two parts the sum of those parts is equal to the original number and none of the parts has value 0.Now given a number, your task is to check if it is Kaprekar number or not.

Examples

Input :  n = 45  
Output : 1
Explanation : 452 = 2025 and 20 + 25 is 45

Input  : n = 297  
Output : 1
Explanation:  2972 = 88209 and 88 + 209 is 297

Input  : n = 10 
Output : 0
Explanation:  102 = 100. It is not a Kaprekar number even if
sum of 100 + 0 is 100. This is because of the condition that 
none of the parts should have value 0.



Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each line contains an integer N.

Output:
For each test case in a new line print 1 if the no is a Kaprekar number else print 0.

Constraints:
1<=T<=10000
2<=N<=10000

Example:
Input:

2
45
10
Output:
1
0

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

Author: Shubham Joshi 1


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.