CF1937A.Shuffle Party

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array a1,a2,,ana_1, a_2, \ldots, a_n . Initially, ai=ia_i=i for each 1in1 \le i \le n .

The operation swap(k)\texttt{swap}(k) for an integer k2k \ge 2 is defined as follows:

  • Let dd be the largest divisor ^\dagger of kk which is not equal to kk itself. Then swap the elements ada_d and aka_k .

Suppose you perform swap(i)\texttt{swap}(i) for each i=2,3,,ni=2,3,\ldots, n in this exact order. Find the position of 11 in the resulting array. In other words, find such jj that aj=1a_j = 1 after performing these operations.

^\dagger An integer xx is a divisor of yy if there exists an integer zz such that y=xzy = x \cdot z .

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t1041 \le t \le 10^4 ). The description of the test cases follows.

The only line of each test case contains one integer nn ( 1n1091 \le n \le 10^9 ) — the length of the array aa .

输出格式

For each test case, output the position of 11 in the resulting array.

输入输出样例

  • 输入#1

    4
    1
    4
    5
    120240229

    输出#1

    1
    4
    4
    67108864

说明/提示

In the first test case, the array is [1][1] and there are no operations performed.

In the second test case, aa changes as follows:

  • Initially, aa is [1,2,3,4][1,2,3,4] .
  • After performing swap(2)\texttt{swap}(2) , aa changes to [2,1,3,4][\underline{2},\underline{1},3,4] (the elements being swapped are underlined).
  • After performing swap(3)\texttt{swap}(3) , aa changes to [3,1,2,4][\underline{3},1,\underline{2},4] .
  • After performing swap(4)\texttt{swap}(4) , aa changes to [3,4,2,1][3,\underline{4},2,\underline{1}] .

Finally, the element 11 lies on index 44 (that is, a4=1a_4 = 1 ). Thus, the answer is 44 .

首页