Hi,

I need some help. I am still a nube so if this is too easy, plz don't flame.
I cannot understand how to approach the problem. Would appreciate any help.

At CodeChef, The Chef can make 10 types of dishes numbered 0 through 9. He
can however only make dishes one after another. Suppose The Chef made dishes
1, 4, 2, 1, 2, 1 on a given day, the number configuration that day would be
142121. On a given day, he makes any number of dishes as long as:

   1. The number configuration for that day is greater than zero(0) and less
   than or equal to 'N'.
   2. Dish 3 is never made *after* dish 1 has been made.
   3. Dish 0 is never the first dish of the day, to be prepared.


How many such unique number configurations exist for a given 'N'?

Examples:

   - 1 is a valid configuration
   - 52 is a valid configuration
   - 12 is a valid configuration
   - 32 is a valid configuration
   - 321 is a valid configuration
   - 3231 is a valid configuration
   - 120 is a valid configuration
   - 012 is not a valid configuration
   - 123 is not a valid configuration
   - 32123 is not a valid configuration

 The first line of the input will contain a number T (1 ≤ T ≤ 1000)
containing the number of test cases. Each line that follows is a separate
test case which has exactly 1 integer 'N' (1 ≤ N < 1018). For each case,
output a single line containing the number of configurations possible for
that 'N'.
*Sample Input:*

5
10
15
115
1113
123456789

*Sample Output:*

10
14
112
1064
92470733

Thanks
Akash

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to