FANCY - FANCY NUMBERS




FANCY NUMBERS
 

Girls usually give only missed calls to their boyfriends and they want them to call back. These boys are now busy with their engineering subjects and cannot remember all girl friends’ mobile number. Because of this, girls make it easy for them by having fancy mobile numbers. A fancy mobile number may contain many continuous digits in it.

For example 9994442200 is a fancy mobile number because the boy can remember simply as triple nine, triple four, double two and double zero. As they are engineering students they do think different. One of the engineering students can spell the above number as double nine, nine, four, double four, two, two, double zero.

The number 100 has only 2 possibilities as it can be spelt as either one, zero, zero (or) one, double zero

Given a mobile number find the number of possibilities that the number can be remembered.


Input Specification:

The first line consists of an integer t denoting the number of test cases. Each test case consists of a mobile number of length <= 30 digits.

Output Specification:

For each test case output the number of possibilities the number can be remembered.

Input Constraints: 1<=t<=100000

Sample Input:

3
100
12345
11112

Sample Output:

2
1
8

WARNING:  Huge data set! Make your I/O optimizations.

 


hide comments
pistachio: 2019-04-04 14:10:02

If you have Runtime Error NZEC in Java please take into account that test no 5, 6 or 7 is not terminated by '\n' thus you have to handel EOF.

anirudnits: 2018-02-10 11:13:21

Got NZEC in python 3.5 but same logic got AC in C++14!

up79: 2017-06-25 12:11:18

AC in one go with string and cin , cout :)

lucy_dragneel: 2017-06-06 00:20:02

use concept of [spoiler] and [spoiler] :)

Last edit: 2017-08-02 13:04:46
rohit9934: 2017-03-13 15:12:40

#math tag should be removed.its #ad-hoc .Learn how to manipulate numbers with strings.

kass_97: 2017-01-06 12:39:39

Took some time until I came up with an easy solution, you can ignore the warning though :p

Rakend Chauhan: 2016-12-22 01:54:35

can be solved with [spoiler].

Last edit: 2016-12-28 19:24:35
prasoonbatham: 2016-10-22 14:52:10

Simple logic. But there's something wrong with test case 7. Please fix it. Gives NZEC in java.

ritik_agr: 2016-06-25 15:19:45

@vineetpratik got AC using string ,cin,cout

suraj: 2016-06-22 12:33:27

accepted with use of cin and cout and string


Added by:cegprakash
Date:2011-12-26
Time limit:0.120s-0.802s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64