CF1937A.Shuffle Party
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a1,a2,…,an . Initially, ai=i for each 1≤i≤n .
The operation swap(k) for an integer k≥2 is defined as follows:
- Let d be the largest divisor † of k which is not equal to k itself. Then swap the elements ad and ak .
Suppose you perform swap(i) for each i=2,3,…,n in this exact order. Find the position of 1 in the resulting array. In other words, find such j that aj=1 after performing these operations.
† An integer x is a divisor of y if there exists an integer z such that y=x⋅z .
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤104 ). The description of the test cases follows.
The only line of each test case contains one integer n ( 1≤n≤109 ) — the length of the array a .
输出格式
For each test case, output the position of 1 in the resulting array.
输入输出样例
输入#1
4 1 4 5 120240229
输出#1
1 4 4 67108864
说明/提示
In the first test case, the array is [1] and there are no operations performed.
In the second test case, a changes as follows:
- Initially, a is [1,2,3,4] .
- After performing swap(2) , a changes to [2,1,3,4] (the elements being swapped are underlined).
- After performing swap(3) , a changes to [3,1,2,4] .
- After performing swap(4) , a changes to [3,4,2,1] .
Finally, the element 1 lies on index 4 (that is, a4=1 ). Thus, the answer is 4 .