CF899D.Shovel Sale

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn shovels in Polycarp's shop. The ii -th shovel costs ii burles, that is, the first shovel costs 11 burle, the second shovel costs 22 burles, the third shovel costs 33 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 99 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 1234512345 and 3745437454 , their total cost is 4979949799 , 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 nn ( 2<=n<=1092<=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<=109n<=10^{9} the answer doesn't exceed 21092·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:

  • 22 and 77 ;
  • 33 and 66 ;
  • 44 and 55 .

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:

  • 11 and 88 ;
  • 22 and 77 ;
  • 33 and 66 ;
  • 44 and 55 ;
  • 55 and 1414 ;
  • 66 and 1313 ;
  • 77 and 1212 ;
  • 88 and 1111 ;
  • 99 and 1010 .

In the third example it is necessary to choose shovels 4949 and 5050 , because the sum of their cost is 9999 , that means that the total number of nines is equal to two, which is maximum possible for n=50n=50 .

首页