#AT1459. C - Buy an Integer

C - Buy an Integer

C - 购买整数

得分:$300$ 分

问题描述

高桥来到一个整数商店购买一个整数。

商店出售从$1$到$10^9$的整数。整数$N$的售价为$A \times N + B \times d(N)$日元(日本货币),其中$d(N)$是$N$的十进制表示的位数。

找出高桥可以用$X$日元购买的最大整数。如果无法购买任何整数,则输出$0$。

约束条件

  • 输入中的所有值都是整数。
  • $1 \leq A \leq 10^9$
  • $1 \leq B \leq 10^9$
  • $1 \leq X \leq 10^{18}$

输入

从标准输入中以以下格式给定:

AA BB XX

输出

输出高桥可以购买的最大整数。如果无法购买任何整数,则输出$0$。

Sample Input 1

10 7 100

Sample Output 1

9

(翻译已死,有事烧纸)The integer 99 is sold for 10×9+7×1=9710 \times 9 + 7 \times 1 = 97 yen, and this is the greatest integer that can be bought. Some of the other integers are sold for the following prices:

  • 10:10×10+7×2=11410: 10 \times 10 + 7 \times 2 = 114 yen
  • 100:10×100+7×3=1021100: 10 \times 100 + 7 \times 3 = 1021 yen
  • 12345:10×12345+7×5=12348512345: 10 \times 12345 + 7 \times 5 = 123485 yen

Sample Input 2

2 1 100000000000

Sample Output 2

1000000000

He can buy the largest integer that is sold. Note that input may not fit into a 3232-bit integer type.

Sample Input 3

1000000000 1000000000 100

Sample Output 3

0