作业帮 > 英语 > 作业

一道叫Card trick 的ACM题感觉知道意思 但是第二个ouput让我纠结

来源:学生作业帮 编辑:作业帮 分类:英语作业 时间:2024/05/10 11:54:59
一道叫Card trick 的ACM题感觉知道意思 但是第二个ouput让我纠结
Card Trick
Time Limit:1000MS Memory Limit:10000K Case Time Limit:30000MS
Total Submit:23 Accepted:15
Solved:14 Submit Users:14
Description:
The magician shuffles a small pack of cards,holds it face down and performs the following procedure:1.The top card is moved to the bottom of the pack.The new top card is dealt face up onto the table.It is the Ace of Spades.2.Two cards are moved one at a time from the top to the bottom.The next card is dealt face up onto the table.It is the Two of Spades.3.Three cards are moved one at a time ...4.This goes on until the nth and last card turns out to be the n of Spades.This impressive trick works if the magician knows how to arrange the cards beforehand (and knows how to give a false shuffle).Your program has to determine the initial order of the cards for a given number of cards,1≤n≤13.
Input:
On the first line of the input is a single positive integer,telling the number of test cases to follow.Each case consists of one line containing the integer n.
Output:
For each test case,output a line with the correct permutation of the values 1 to n,space separated.The first number showing the top card of the pack,etc ...
Example Input:
2
4
5
Example Output:
2 1 4 3
3 1 4 5 2
我觉得的意思是 有(输入的)N张牌 他先把顶那张放牌底 然后 下一张 是他想要黑桃X 然后把黑桃抽出 再 把顶两张放牌底 然后下一张是他要的黑桃Y 然后把黑桃抽出 再把三张放牌底..以此类推问你 他放黑桃的位置 是这个意思吗?
但是第二个output怎么是3 1 4 5 不因该是2 5 1 3 我到底哪里理解错了...
魔术的内容:一叠牌 如:2 1 4 3 ,把最上面1张牌(也就是2)放到底下去,这时牌序为(1 4 3 2)翻开第一张是1(A),把A拿走,牌序(4 3 2),把最上面2张牌(也就是4 3)放到底下去(2 4 3),翻开第一张是2,把2拿走(4 3)然后4 3进行3次交换后,翻开第一张牌是3.
题目的意思是:输入n表示牌的张数,要你输出它的排序,使得其满足如上的要求,懂不?
再问: 那跟我的理解又神恶魔不同 你看看第二个输出你这么理解 能对不...
再答: 第二个是:把最上面的1张牌(3)放到最下面去(1 4 5 2 3),翻开第一张是1,把1拿掉(4 5 2 3)把上面2张放到底下去(2 3 4 5)翻开第一张是2,把2拿掉(3 4 5)把上面3张放到底下去还是(3 4 5)翻开第一张是3,把3 拿掉(4 5)把上面4张放到底下去(可以循环抽放)(4 5)翻开第一张是4.。。。。。。。。。。