ANARC05H  Chop Ahoy! Revisited!
Given a nonempty string composed of digits only, we may group these digits into subgroups (but maintaining their original order) if, for every subgroup but the last one, the sum of the digits in a subgroup is less than or equal to the sum of the digits in the subgroup immediately on its right. Needless to say, each digit will be in exactly one subgroup.
For example, the string 635 can only be grouped in one subgroup [635] or in two subgroups as follows: [635] (since 6 < 8.) Another example is the string 1117 which can be grouped in one subgroup [1117] or as in the following: [1117], [1117], [1117], [1117], [1117] and [1117] but not any more, hence the total number of possibilities is 7.
Write a program that computes the total number of possibilities of such groupings for a given string of digits.
Input
Your program will be tested on a number of test cases. Each test case is speciﬁed on a separate line. Each line contains a single string no longer than 25, and is made of decimal digits only.
The end of the test cases is identiﬁed by a line made of the word "bye" (without the quotes.) Such line is not part of the test cases.
Output
For each test case, write the result using the following format:
k. n
where k is the test case number (starting at 1,) and n is the result of this test case.
Example
Input: 635 1117 9876 bye Output: 1. 2 2. 7 3. 2
hide comments
avinash kumar:
20121215 19:29:47
i am trying to solve it by recursion with for loop.


rohitjv:
20121211 04:35:07
very easy dp


gourav:
20120929 07:52:03
yipeeeeeeee!! 15th problem now ;) cool 

Surya:
20120627 05:33:00
@ ;) : Max string length is only 25. So its not a matter of time. Even recursion will do without deeping out! 

npsabari:
20120626 20:15:18
Naive Brute Force method is getting AC in 0.00 sec!! 

data:
20120619 18:35:34
easy one:)


Romal Thoppilan:
20120611 07:13:46
yaah .. just changing gets() to scanf("%s") worked !!


M LOHIT:
20120523 13:24:34
In test cases lines are ending with "\r\n" (Windows style) instead of '\n'.


Kashyap Krishnakumar:
20110505 01:31:37
Nice problem. Some submissions in "TEXT" have been accepted. I guess it has to be disabled. Last edit: 20110505 01:33:26 

Jacob:
20100120 19:05:00
Dodgy white space on the input here too. 
Added by:  ~!(*(@*!@^& 
Date:  20090705 
Time limit:  1s2s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  ANARC 2005 