| 比赛 | 
    20120224 | 
    评测结果 | 
    WWWWWWWWWW | 
    | 题目名称 | 
    小球钟—时间与运动 | 
    最终得分 | 
    0 | 
    | 用户昵称 | 
    王者自由 | 
    运行时间 | 
    0.000 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    0.00 MiB  | 
    | 提交时间 | 
    2012-02-24 19:47:49 | 
显示代码纯文本
#include <cstdio>
#include <stack>
#include <queue>
using namespace std;
int n, p[1000];
stack<int> a, b, c;
queue<int> q;
int main() {
    freopen("xqz.in", "r", stdin);
    freopen("xqz.out", "w", stdout);
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
        q.push(i);
    for(; ; ) {
        a.push(q.front());
        q.pop();
        if(a.size() > 4) {
            for(int i=0; i<4; i++) {
                q.push(a.top());
                a.pop();
            }
            b.push(a.top());
            a.pop();
            if(b.size() > 11) {
                for(int i=0; i<4; i++) {
                    q.push(b.top());
                    b.pop();
                }
                c.push(b.top());
                b.pop();
                if(c.size() > 11) {
                    for(int i=0; i<11; i++) {
                        q.push(c.top());
                        c.pop();
                    }
                    q.push(c.top());
                    c.pop();
                    break;
                }
            }
        }
    }
    int j = 1;
    while(!q.empty()) {
        p[j++] = q.front();
        q.pop();
        fprintf(stderr, "%d ", p[j-1]);
    }
    return 0;
}