Fascinating Number
Submissions: 3045   Accuracy:

29.3%

  Difficulty: School   Marks: 0
*School Problem's Submission isn't counted in score!

Given a number N. Your task is to check whether it is fascinating or not.
Fascinating Number : When a number( 3 digit or more) is multiplied by 2 and 3 ,and when both these products are concatenated with the original number, then it results in all digits from 1 to 9 present exactly once.

Input:
First line contains number of test cases T. Then following T lines contains a positive integer N.

Output:
Print "1" (without quotes) if given number is fascinating else "0" (without quotes) .

Constraints:
1 <= T <= 200
100 <= N <= 107

Example:
Input:
3
192
853

Output:
1
0
Explanation:
Testcase 1:
After multiplication with 2 and 3, and concatenating with original number, number will become 192384576 which contains all digits from 1 to 9.

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

Contributor: Mudit Maheshwari
Author: atharv


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.