304715: CF899D. Shovel Sale
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Shovel Sale
题意翻译
用小于等于 $n$ 的任意两个不同的正整数相加,求末尾的 $9$ 的位数最多时的相加方案数。题目描述
There are $ n $ shovels in Polycarp's shop. The $ i $ -th shovel costs $ i $ burles, that is, the first shovel costs $ 1 $ burle, the second shovel costs $ 2 $ burles, the third shovel costs $ 3 $ burles, and so on. Polycarps wants to sell shovels in pairs. Visitors are more likely to buy a pair of shovels if their total cost ends with several $ 9 $ s. Because of this, Polycarp wants to choose a pair of shovels to sell in such a way that the sum of their costs ends with maximum possible number of nines. For example, if he chooses shovels with costs $ 12345 $ and $ 37454 $ , their total cost is $ 49799 $ , it ends with two nines. You are to compute the number of pairs of shovels such that their total cost ends with maximum possible number of nines. Two pairs are considered different if there is a shovel presented in one pair, but not in the other.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 2<=n<=10^{9} $ ) — the number of shovels in Polycarp's shop.
输出格式
Print the number of pairs of shovels such that their total cost ends with maximum possible number of nines. Note that it is possible that the largest number of 9s at the end is 0, then you should count all such ways. It is guaranteed that for every $ n<=10^{9} $ the answer doesn't exceed $ 2·10^{9} $ .
输入输出样例
输入样例 #1
7
输出样例 #1
3
输入样例 #2
14
输出样例 #2
9
输入样例 #3
50
输出样例 #3
1