FANCY - 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.
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.
For each test case output the number of possibilities the number can be remembered.
Input Constraints: 1<=t<=100000
3 100 12345 11112
2 1 8
WARNING: Huge data set! Make your I/O optimizations.
Same code gives AC in cpp, but fails in java with NZEC error
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.
Got NZEC in python 3.5 but same logic got AC in C++14!
AC in one go with string and cin , cout :)
use concept of [spoiler] and [spoiler] :)Last edit: 2017-08-02 13:04:46
#math tag should be removed.its #ad-hoc .Learn how to manipulate numbers with strings.
Took some time until I came up with an easy solution, you can ignore the warning though :p
can be solved with [spoiler].Last edit: 2016-12-28 19:24:35
Simple logic. But there's something wrong with test case 7. Please fix it. Gives NZEC in java.
@vineetpratik got AC using string ,cin,cout