hdu1276士兵队列训练问题(队列模拟)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1276

题目大意:balabala快看题,今天小学弟做题说过不去,我便过来做了一下

题目思路:模拟

注意:输入2的时候要输出1 2这个点比较坑!!!还有要读清楚规则。声明两个队列然后模拟一下就好了!!!

代码:

#include 
using namespace std;
int main()
{
    queueq1;
    queueq2;
    int t;while(~scanf("%d",&t)){
        while(t--){
        int x;scanf("%d",&x);
        for(int i=1;i<=x;i++){
            q1.push(i);
        }
        while(1){
            if(q1.size()<=3){
                printf("%d",q1.front());q1.pop();
                while(!q1.empty()){
                    printf(" %d",q1.front());
                    q1.pop();
                }
                break;
            }
            int num=1;
            while(!q1.empty()){
                if(num%2==1) {q2.push(q1.front());/*cout<


你可能感兴趣的:(杂题)