100 #ABC146C. [ABC146C] Buy an Integer

[ABC146C] Buy an Integer

Score : 300300 points

Problem Statement

Takahashi has come to an integer shop to buy an integer.

The shop sells the integers from 11 through 10910^9. The integer NN is sold for A×N+B×d(N)A \times N + B \times d(N) yen (the currency of Japan), where d(N)d(N) is the number of digits in the decimal notation of NN.

Find the largest integer that Takahashi can buy when he has XX yen. If no integer can be bought, print 00.

Constraints

  • All values in input are integers.
  • 1A1091 \leq A \leq 10^9
  • 1B1091 \leq B \leq 10^9
  • 1X10181 \leq X \leq 10^{18}

Input

Input is given from Standard Input in the following format:

AA BB XX

Output

Print the greatest integer that Takahashi can buy. If no integer can be bought, print 00.

10 7 100
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
2 1 100000000000
1000000000

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

1000000000 1000000000 100
0
1234 56789 314159265
254309