#include <cstdio> #include <string> #include <vector> using namespace std; vector<string> data; char inputbuffer1[ 1024 ]; char inputbuffer2[ 1024 ]; void getnewstring( const string& left , const string& right ) { string result; int i = 0 , j = 0 ; char mid = 0 ; int mid2; while( i != left.size() && j != right.size() ) { mid2 = left[i] + right[j] + mid; result.push_back( mid2 % 10 ); mid = mid2 / 10; ++i;++j; } while( i != left.size() ) { mid2 = left[i] + mid; result.push_back( mid2 % 10 ); mid = mid2 / 10; ++i; } while( j != right.size() ) { mid2 = right[j] + mid; result.push_back( mid2 % 10 ); mid = mid2 / 10; ++j; } if( mid != 0 ) result.push_back( mid ); data.push_back( result ); } int cmp( const string& left , const string& right ) { if( left.size() < right.size() ) return -1; else if( left.size() > right.size() ) return 1; string::const_reverse_iterator i , j; for( i = left.rbegin() ,j = right.rbegin() ; i != left.rend() ; ++i , ++j ) if( *i < *j ) return -1; else if( *i > *j ) return 1; return 0; } int binarysearchupper( int left , int right ,const string& key ) { int middle; while( left <= right ) { middle = ( left + right )/2; if( cmp( data[middle] , key ) <= 0 ) left = middle + 1; else right = middle - 1; } return right; } int binarysearchlower( int left , int right ,const string& key ) { int middle; while( left <= right ) { middle = ( left + right )/2; if( cmp( data[middle] , key ) < 0 ) left = middle + 1; else right = middle - 1; } return left; } void input( string & a ) { int i = 0 ; int j = a.size() - 1; for( ; i < j ; ++i , --j ) { swap( a[i] , a[j] ); a[i] -= '0'; a[j] -= '0'; } if( i == j ) a[i] -= '0'; while( a.size() != 0 && *a.rbegin() == 0 ) a.erase( a.size() - 1 ); } void output( string & a ) { for( int i = 0 ; i != a.size() ; ++i ) printf("%c",a[i] + '0'); printf("/n"); } int main() { const int n = 500; string first; first.push_back(1); data.push_back( first ); first[0] = 2; data.push_back( first ); for( int i = 0 ; i != n ; ++i ) getnewstring( *data.rbegin() , *( ++ data.rbegin() )); //输入完数据了 string left; string right; int result1; int result2; while( scanf("%s%s",inputbuffer1,inputbuffer2) ) { left = inputbuffer1; right = inputbuffer2; input(left);input(right); if( left.size() == 0 && right.size() == 0 ) break; result1 = binarysearchlower( 0 , data.size() - 1 , left ); result2 = binarysearchupper( 0 , data.size() - 1 , right ); if( result1 <= result2 ) printf("%d/n",result2 - result1+1); else printf("0/n"); } return 0; }