http://codeforces.com/contest/374/problem/B
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 6 char str[200001]; 7 8 int main() 9 { 10 while(scanf("%s",str)!=EOF) 11 { 12 int k=strlen(str); 13 __int64 ans=1; 14 for(int i=0; i<k;) 15 { 16 if((str[i]-'0')+(str[i+1]-'0')==9&&i+1<k) 17 { 18 __int64 c=1; 19 while((str[i]-'0')+(str[i+1]-'0')==9) 20 { 21 c++; 22 i++; 23 } 24 if(c%2==0) ans*=1; 25 else ans*=(c/2+1); 26 } 27 i++; 28 } 29 printf("%I64d ",ans); 30 } 31 return 0; 32 }