【HDOJ】2319 Card Trick

时间:2023-03-08 16:03:44
【HDOJ】2319 Card Trick

水题,STL双端队列。

 /* 2319 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <deque>
#include <algorithm>
using namespace std; int main() {
int n, t;
int i, j, k;
deque<int> Q; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif scanf("%d", &t);
while (t--) {
scanf("%d", &n);
Q.push_front(n);
for (i=n-; i>=; --i) {
Q.push_front(i);
for (j=; j<i; ++j) {
k = Q.back();
Q.pop_back();
Q.push_front(k);
}
}
k = Q.front();
Q.pop_front();
printf("%d", k);
while (!Q.empty()) {
k = Q.front();
Q.pop_front();
printf(" %d", k);
}
printf("\n");
} return ;
}