Lucky Number
Submissions: 4506   Accuracy:

22.51%

  Difficulty: Easy   Marks: 2

A n digit number has n*(n+1)/2 sub-numbers.  For example, all possible sub-numbers of 975 are 9 7 5 97 75 975. A number is called Lucky if all sub-numbers have different digit product.  Digit product of a number is product of its digits.  

For example, the number 23 is Lucky.  Subsequences of it are 2, 3 and 23 and digit products are 2, 3 and 6 respectively (All digit products are different). 975 is also lucky.

 

Input:

The first line contains an integer T, depicting total number of test cases. 
Then following T lines contains an integer N .
Output:

Print 1 if number is lucky else print 0.

Constraints:

1<=T<=100

1<=N<=1010
Example:

Input:

2
324

323

Output:

1
0

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

Author: bhawnamait


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.