The magician shuffles a small pack of cards, holds it face down and performs the following procedure:
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.
2 4 5
2 1 4 3 3 1 4 5 2
題意:給你n張牌,分別是1-n
第一次把最上面1張放到最下面,亮出當前最上面的牌 使其為1
第二次把最上面2張放到最下面,亮出當前最上面的牌 使其為2
第三次把最上面3張放到最下面,亮出當前最上面的牌 使其為3
..............
模擬一下過程就好了 當然如果你對時間更苛刻 由於最多只有13張牌 可以把結果存在一個數組
#include#include using namespace std; int main() { int ncase; int order[13]; scanf("%d",&ncase); while(ncase--) { int n; scanf("%d",&n); queue s; for(int i=0;i