#agc061a. [agc061_a]Long Shuffle

[agc061_a]Long Shuffle

题目描述

你有一个排列长度为 n(n1018)n(n\le10^{18}) 的排列 AA,初始 Ai=iA_i=i,现在对它进行一次 shuffle(1,n)\mathrm{shuffle}(1,n) 操作。shuffle(L,R)\mathrm{shuffle}(L,R) 的定义如下:

  • R = L + 1 R\ =\ L\ +\ 1 时,swap(AL,AR)\mathrm{swap}(A_L,A_R)
  • 否则,依次执行 shuffle(L,R1)\mathrm{shuffle}(L,R-1), shuffle(L+1,R)\mathrm{shuffle}(L+1,R)

您需要求出 shuffle(1, n) \mathrm{shuffle}(1,\ n) 执行完毕后,Ak(1kn)A_k (1\le k\le n) 的值。共 TT 组数据。