//////////////////////////////////////// ///////////
// 1677474 14:46:52 accepted 2202 C ++ 0 192 VRS
// Number of codes that are decoded after calculation
// Use the divide and conquer method to divide the string s into S1 and S2, and then multiply the numbers of the two parts.
// Note: When merging S1 and S2, consider the adjacent two numbers to form an encoding, and discuss multiple cases of zero.
# Include <iostream>
# Include <string>
Using namespace STD;
Char s [10000];
Bool conbine (char s [], int L, int R) // determines whether the two numbers can be encoded. 1 is returned; otherwise, 0 is returned.
{
If (s [l]> '2' | s [l] = '0') return 0;
If (s [l] = '2' & S [R]> '6') return 0;
Return 1;
}
Long acode (char s [], int L, int R) // binary recursive calculation count
{
Long mid, ansl, ansr, ans;
If (L = r) return 1; // 1 returns 1
If (L + 1 = r) // Number of 2
If (s [R] = '0') // when the second number is 0, there is only one encoding.
Return 1;
Else
Return conbine (S, L, R) + 1;
If (L + 2 = r) // number of 3
If (s [L + 1] = '0' | s [R] = '0') // when the second or third number is 0, there is only one encoding.
Return 1;
Else
Return conbine (S, l, l + 1) + conbine (S, L + 1, R) + 1;
Mid = (R-l + 1)/2-1 + L; // The median between l and R
If (s [Mid + 1] = '0') // when the first element of S2 is 0, for example, "1101 ", separate s [Mid] And s [Mid + 1] without computing
{// Two-part quantity
Ansl = acode (S, L, mid-1 );
Ansr = acode (S, Mid + 2, R );
Return ansl * ansr;
}
Ansl = acode (S, L, mid );
Ansr = acode (S, Mid + 1, R );
Ans = ansl * ansr;
If (s [Mid + 2] = '0') return ans; // when "1011011" occurs, because the first element "1" of S2 needs to be
// "0" makes up an encoding. Therefore, the combination of S [Mid] And s [Mid + 1] is not required.
If (conbine (S, mid, Mid + 1 ))
{
Ansl = acode (S, L, mid-1 );
Ansr = acode (S, Mid + 2, R );
Return ans + ansl * ansr;
}
Else return ans;
}
Int main ()
{
Int Len;
While (CIN> S & S [0]! = '0 ')
{
Len = strlen (s );
Cout <acode (S, 0, len-1) <Endl;
}
Return 0;
}