Under construction

Still being built. Things may change

Bitcoin Halving

Interview

Time limit1sMemory limit1024 MB

Summary
Given the initial reward R, the halving interval K, and a block number M, print the mining reward of block M.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

A professor preparing an Information Security course in the Department of Big Data Information Security at Seoul Cyber University was talking with Professor Cheon about blockchain. He became curious about the mining reward of a specific block, since Bitcoin's mining reward halves each time a halving occurs.

Bitcoin's block reward is halved at regular intervals, following these rules.

  • Initial reward: Starting from block 00, the initial mining reward of each block is RR satoshi.
  • Halving interval: Every KK blocks, the mining reward is halved. (Fractions are discarded when they occur, so the mining reward is always an integer.)
  • Reward expiration: When the mining reward becomes smaller than 11 satoshi, it disappears, and the mining reward of every block after that is 00 satoshi.

For example, suppose the initial reward is 5 000 000 0005\,000\,000\,000 satoshi and the halving interval is 210 000210\,000 blocks. Then the reward for blocks 00 through 209 999209\,999 is 5 000 000 0005\,000\,000\,000 satoshi, the reward for blocks 210 000210\,000 through 419 999419\,999 is 2 500 000 0002\,500\,000\,000 satoshi, ⋯\cdots, the reward for blocks 6 720 0006\,720\,000 through 6 929 9996\,929\,999 is 11 satoshi, and the reward for block 6 930 0006\,930\,000 and every block after it is 00 satoshi.

The two professors asked you to analyze this. Given the initial reward RR, the halving interval KK, and the number MM of a specific block, print the mining reward of block MM.

Input

The first line contains the initial reward RR, the halving interval KK, and the number MM of a specific block, in that order. (1≤R≤1010;2≤K≤1010;0≤M≤1010)(1 \le R \le 10^{10}; 2 \le K \le 10^{10}; 0 \le M \le 10^{10})

All numbers in the input are integers.

Output

On the first line, print the mining reward of block MM.

Examples5

  1. Example 1

    Input
    1 2 1
    
    Expected output
    1
    
  2. Example 2

    Input
    1 2 2
    
    Expected output
    0
    
  3. Example 3

    Input
    5000000000 210000 209999
    
    Expected output
    5000000000
    
  4. Example 4

    Input
    5000000000 210000 6930000
    
    Expected output
    0
    
  5. Example 5

    Input
    50 21 21
    
    Expected output
    25