逆向模拟操作
构造队列
http://www.nowcoder.com/questionTerminal/657d09e2b3704574814089ba8566d98d
由原来的队列经过一系列操作后可以得到[1,2,3,4.....n]这样的队列,那么把所有的操作逆向回去,就能由[1,2,3,4,.....n]得到原来的队列。
from collections import deque T = int(input()) while(T): n = int(input()) queue = deque() res = deque([i for i in range(1,n+1)]) #res = [1,2,3,4,5,6,7...n] while(res): target = res.pop() queue.appendleft(target) target = queue.pop() queue.appendleft(target) q = [str(i) for i in queue] print(' '.join(q)) T = T-1