201270: [AtCoder]ARC127 A - Leading 1s
Memory Limit:1024 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Score : $300$ points
Problem Statement
For an integer $x$, let $f(x)$ be the number of leading ones in the decimal notation of $x$. For example, we have $f(1)=1,f(2)=0,f(10)=1,f(11)=2,f(101)=1$.
Given an integer $N$, find $f(1)+f(2)+\cdots+f(N)$.
Constraints
- $1 \leq N \leq 10^{15}$
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
$N$
Output
Print the answer.
Sample Input 1
11
Sample Output 1
4
We have $f(2)=f(3)=\cdots =f(9)=0$. The answer is $f(1)+f(10)+f(11)=4$.
Sample Input 2
120
Sample Output 2
44
Sample Input 3
987654321
Sample Output 3
123456789