Program time limit: 1 second
Program memory limit: 512 MB
Aaron loves arrays for their fast lookup speed. When he is bored, he chooses a positive integer $n$, and puts all the positive integers up to $n$ in order into an array. He then removes half the numbers from the array, and reindexes the array so that there are no gaps. He repeats this until he is left with one number. Recently, Aaron has been trying to convince Eve to join his hobby. However, Eve loves her even numbers too much, so every turn she will only remove every number at an odd position. Unfortunately, Eve is not particularly impressed with Aaron's antics, and doesn't want to waste any more time doing this by hand. She enlists your help to find the final result whenever Aaron forces her to take part in this mentally exhilarating activity.
The first and only line of input contains one integer $n$.
You should read from standard input.
In Python, you could use the line n = int(input())
.
In C or C++, you could use the line long long int n; scanf("%lld", &n);
.
For all test cases:
Output a single integer, the last integer remaining at the end of the process.
You should write to standard output.
In Python, you could use the line print(answer)
.
In C or C++, you could use the line printf("%lld\n", answer);
.
7
4
1 2 3 4 5 6 7
1 2 3 4 5 6 7
2 4 6
2 4 6
4
Your program will be run on the 1 sample case and multiple secret test cases one after another, and if it produces the correct output for all test cases, it solves the task. Recall that your final score on the task is the score of your highest scoring submission.
You haven't submitted to this task.