8620: NIO's Sword

内存限制:256 MB 时间限制:1 S
题面:传统 评测方式:Special Judge 上传者:
提交:0 通过:0

题目描述

NIO is playing a new game. In this game, NIO has a sword with attack power represented by an integer AAA. Initially, A=0A=0A=0. There are also nnn enemies in the game. NIO has to kill them in order, which means NIO must kill the (i−1)(i-1)(i1)-th enemy before killing the iii-th enemy for each iii (2≤i≤n2\le i\le n2in). For the iii-th enemy, NIO can kill it if and only if A≡i(modn)A\equiv i \pmod{n}Ai(modn).

Fortunately, NIO can upgrade his sword at any moment for any number of times. Each time NIO upgrades his sword, he first chooses an integer xxx (0≤x≤90\le x\le 90x9), then changes the attack power of the sword from AAA to 10×A+x10\times A+x10×A+x.

NIO wants to minimize the number of times to upgrade the sword so that he can win the game as fast as possible. Can you help him to find the minimum times?

输入格式

The first line contains one integer nnn (1≤n≤1061\le n\le 10^{6}1n106), indicating the number of enemies.

输出格式

Output one integer indicating the minimum times to upgrade the sword.

输入样例 复制

4

输出样例 复制

4

数据范围与提示

Here is a possible solution for the example:
- The attack power of the sword when killing the first enemy can be 10×0+1=110\times0+1=110×0+1=1.
- The attack power of the sword when killing the second enemy can be 10×1+4=1410\times1+4=1410×1+4=14.
- The attack power of the sword when killing the third enemy can be 10×14+7=14710\times14+7=14710×14+7=147.
- The attack power of the sword when killing the fourth enemy can be 10×147+2=147210\times147+2=147210×147+2=1472.
So he needs to upgrade the sword at least four times.

分类标签