This function receives the string representation of the number and precomputes the sum array
void prepareSum ( string s ) { sum [ 0 ] = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) sum [ i + 1 ] = sum [ i ] + toInt ( s [ i ] ) ; }