# Include < Stdio. h >
# Include < Math. h >
Int Fun ( Int Num)
{
Int K = 0 ;
Int Sum = 0 ;
Int Pw_k0 = ( Int ) Pow ( 10 , K ); // The value of pw_k0 is 10 ^ K.
Int Pw_k1 = ( Int ) Pow ( 10 , K + 1 ); // Pw_k1 is 10 ^ (k + 1)
While (Num - Pw_k0) > = 0 ) // If num is less than 10 ^ K, it indicates that there is no value on the K bit, that is, output.
{
Int X = (Num % Pw_k1 - Num % Pw_k0) / Pw_k0; // Take the number on the K-bit,
If ( 0 = X)
{
Sum = Sum + Num / Pw_k1 * Pw_k0; // When the number on K bit is 0, the number of all numbers on this bit is 1.
}
Else If ( 1 = X)
{
Sum = Sum + Num / Pw_k1 * Pw_k0 + Num % Pw_k0 + 1 ; // When the number on the K bit is 1, the number of all numbers on this bit is 1.
}
Else
{
Sum = Sum + Num / Pw_k1 * Pw_k0 + Pw_k0; // When the number in the K bit is greater than 1, the number of all numbers in this bit is 1.
}
K ++ ;
Pw_k0 = ( Int ) Pow ( 10 , K );
Pw_k1 = ( Int ) Pow ( 10 , K + 1 );
}
Return SUM;
}
Int Main ()
{
Printf ( " % D \ n " , Fun ( 11 ));
Return 0 ;
}