#C7825. Steps to Power On All Robots
Steps to Power On All Robots
Steps to Power On All Robots
You are given n robots arranged in a circular formation. Initially, one of them (at position k) is powered on. In each step, the power signal spreads in a fixed pattern such that after the process completes, all robots end up powered on.
On analyzing the problem, you will notice that no matter which robot is initially powered, the minimum number of steps required to power on all robots is determined solely by the total number n. In fact, the answer to the problem is the ceiling of \(\frac{n}{2}\), i.e. \(\lceil \frac{n}{2} \rceil\).
Your task is to implement a function that reads two integers n and k from the standard input and outputs the minimum number of steps required to power on all robots.
Note: Although the starting robot k is provided, the answer depends solely on n.
inputFormat
The input consists of a single line containing two space-separated integers:
- n (1 ≤ n ≤ 109): The number of robots arranged in a circle.
- k (1 ≤ k ≤ n): The index of the initially powered robot.
Input is provided via standard input (stdin).
outputFormat
Output a single integer — the minimum number of steps required to power on all the robots.
The result should be printed to standard output (stdout).
## sample5 3
3
</p>