ANARC05H - Chop Ahoy! Revisited!
Given a non-empty string composed of digits only, we may group these digits into sub-groups (but maintaining their original order) if, for every sub-group but the last one, the sum of the digits in a sub-group is less than or equal to the sum of the digits in the sub-group immediately on its right. Needless to say, each digit will be in exactly one sub-group.
For example, the string 635 can only be grouped in one sub-group  or in two sub-groups as follows: [6-35] (since 6 < 8.) Another example is the string 1117 which can be grouped in one sub-group  or as in the following: [1-117], [1-1-17], [1-11-7], [1-1-1-7], [11-17] and [111-7] 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.
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.
For each test case, write the result using the following format:
where k is the test case number (starting at 1,) and n is the result of this test case.
Input: 635 1117 9876 bye Output: 1. 2 2. 7 3. 2
yipeeeeeeee!! 15th problem now ;) cool
@ ;) : Max string length is only 25. So its not a matter of time. Even recursion will do without deeping out!
Naive Brute Force method is getting AC in 0.00 sec!!
yaah .. just changing gets() to scanf("%s") worked !!
In test cases lines are ending with "\r\n" (Windows style) instead of '\n'.
Nice problem. Some submissions in "TEXT" have been accepted. I guess it has to be disabled.Last edit: 2011-05-05 01:33:26
Dodgy white space on the input here too.
Something is wrong with the tests. I think there is no "bye". Break your code when the first character is not a digit.