A number on the board

2.8

41 votes
Ternary search, Math Basic, C++, Basic Math, Binary Search, Math
Problem

Number 1 is written on the whiteboard. Perform exactly c operations on the written number. In each step, you can do one of the following operations:

  • Multiply the number on the board by a
  • Add b to the number on the board

Determine the maximum number you can reach after exactly c operations.

Input format

The first line of input contains a,b,c respectively.

Note: a is a decimal number and b and c are integers.

Output format

If the correct answer of the problem is Ans, then you must print log2Ans. If your answer is O, then your answer is considered correct if |(log2Ans)O|log2Ans106.

Note: The output should only consist of digits and dot. For example 235653455.5277 is correct and 2.356534555277e+8 is not correct. (You can use setpresicion function in C++.)

Constraints

0a103

1b,c1018

1b×c1018

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In this example, we use a sumation and a multiplication, respectievly. After first step, the number would be 1+4=5 and then by a multiplication, the number would be 5×3.2=16.

So the answer is 16, but we should output the logarithm. So log216=4

Editor Image

?