Bitcoin Halving
InterviewTime limit1sMemory limit1024 MB
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 , the initial mining reward of each block is satoshi.
- Halving interval: Every 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 satoshi, it disappears, and the mining reward of every block after that is satoshi.
For example, suppose the initial reward is satoshi and the halving interval is blocks. Then the reward for blocks through is satoshi, the reward for blocks through is satoshi, , the reward for blocks through is satoshi, and the reward for block and every block after it is satoshi.
The two professors asked you to analyze this. Given the initial reward , the halving interval , and the number of a specific block, print the mining reward of block .
Input
The first line contains the initial reward , the halving interval , and the number of a specific block, in that order.
All numbers in the input are integers.
Output
On the first line, print the mining reward of block .