// http://www.spoj.com/problems/ACODE/
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn = 50000 + 10;
int n;
char s[ maxn ];
long long f[ maxn ];
void work()
{
f[ 0 ] = 1;
f[ 1 ] = 1;
for( int i = 2; i <= n; i ++ )
{
f[ i ] = 0;
if( s[ i ] != '0' ) f[ i ] += f[ i - 1 ];
if( s[ i - 1 ] != '0' && ( s[ i - 1 ] - '0' ) * 10 +
( s[ i ] - '0' ) <= 26 ) f[ i ] += f[ i - 2 ];
}
cout << f[ n ] << endl;
}
int main()
{
while( true )
{
scanf( "%s" , s + 1 );
if( s[1] == '0' ) break;
n = strlen( s + 1 );
work();
}
return 0;
}
SPOJ Alphacode
最新推荐文章于 2018-04-10 21:12:00 发布