A11380 | Shovel Sale
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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}$ .
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
In the first example the maximum possible number of nines at the end is one. Polycarp cah choose the following pairs of shovels for that purpose:
- $2$ and $7$ ;
- $3$ and $6$ ;
- $4$ and $5$ .
In the second example the maximum number of nines at the end of total cost of two shovels is one. The following pairs of shovels suit Polycarp:
- $1$ and $8$ ;
- $2$ and $7$ ;
- $3$ and $6$ ;
- $4$ and $5$ ;
- $5$ and $14$ ;
- $6$ and $13$ ;
- $7$ and $12$ ;
- $8$ and $11$ ;
- $9$ and $10$ .
In the third example it is necessary to choose shovels $49$ and $50$ , because the sum of their cost is $99$ , that means that the total number of nines is equal to two, which is maximum possible for $n=50$ .
- $2$ and $7$ ;
- $3$ and $6$ ;
- $4$ and $5$ .
In the second example the maximum number of nines at the end of total cost of two shovels is one. The following pairs of shovels suit Polycarp:
- $1$ and $8$ ;
- $2$ and $7$ ;
- $3$ and $6$ ;
- $4$ and $5$ ;
- $5$ and $14$ ;
- $6$ and $13$ ;
- $7$ and $12$ ;
- $8$ and $11$ ;
- $9$ and $10$ .
In the third example it is necessary to choose shovels $49$ and $50$ , because the sum of their cost is $99$ , that means that the total number of nines is equal to two, which is maximum possible for $n=50$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted