Different ways to Spell a Number
Submissions: 833   Accuracy:

31.03%

  Difficulty: Basic   Marks: 1

Given a  number. The number may contain many same continuous digits in it. The task is to count number of ways to spell the number.
For example, consider 8884441100, one can spell it simply as triple eight triple four double two and double zero. One can also spell as double eight, eight, four, double four, two, two, double zero.

Examples:

Input :  num = 100
Output : 2
The number 100 has only 2 possibilities, 
1) one zero zero 
2) one double zero.

Input : num = 11112
Output: 8
1 1 1 1 2, 11 1 1 2, 1 1 11 2, 1 11 1 2
11 11 2, 1 111 2, 111 1 2, 1111 2

Input : num = 8884441100
Output: 64

Input : num = 12345
Output: 1

Input : num = 11111
Output: 16

 

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

Output:
For each test case in a new line print number of ways we can spell N.

Constraints:
1<=T<=100
1<=N<=10^50

Example:
Input

2
100
11112


Output
2
8

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

Author: kartik


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.