Special Small Fountain
Time limit1sMemory limit512 MB
Given x0 and N, apply the rule that maps x to floor(x/2) XOR 6 when x is even or 2x XOR 6 when x is odd, N times, and print the result.
- Level
Easy2 of 10
- Topics
- Implementation, Bit manipulation, Simulation
- Solved
- No attempts yet
Problem
This problem is the same as the "Special Big Fountain" problem, except for the limits on and .
NLCS has many fountains.
The water height in a fountain changes by a fixed rule. If the height of the fountain at integer time is the integer , then is when is even, and when is odd.
Given the height of the fountain at time 0, write a program that finds the height of the fountain at time .
Input
The first line contains and , the height of the fountain at time 0 and the time . Both and are integers.
Output
Print the height of the fountain at time on the first line.
Constraints
Hints
- is the largest integer less than or equal to .
- is the bitwise XOR operator. See the Wikipedia article on bitwise operations for details. Most programming languages implement bitwise XOR as
^.