zoukankan      html  css  js  c++  java
  • CodeForces 669D Little Artem and Dance

    模拟。

    每个奇数走的步长都是一样的,每个偶数走的步长也是一样的。

    记$num1$表示奇数走的步数,$num2$表示偶数走的步数。每次操作更新一下$num1$,$num2$。最后输出。

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const double pi=acos(-1.0),eps=1e-6;
    void File()
    {
        freopen("D:\in.txt","r",stdin);
        freopen("D:\out.txt","w",stdout);
    }
    template <class T>
    inline void read(T &x)
    {
        char c=getchar(); x=0;
        while(!isdigit(c)) c=getchar();
        while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
    }
    
    bool f;
    int n,q,num1,num2;
    int ans[1000010];
    
    int M(int x)
    {
        if(x>=0) return x%n;
        int y=-x; int p=y/n+1;
        return (x+n*p)%n;
    }
    
    int main()
    {
        scanf("%d%d",&n,&q); f=1;
        for(int i=1;i<=q;i++)
        {
            int op; scanf("%d",&op);
            if(op==1)
            {
                int x; scanf("%d",&x);
                num1=M(num1+x), num2=M(num2+x);
                if(x%2!=0) f=f^1;
            }
            else
            {
                if(f==0) num2=M(num2+1), num1=M(num1-1);
                else num1=M(num1+1), num2=M(num2-1);
                f=f^1;
            }
        }
    
        for(int i=1;i<=n;i++)
        {
            int pos;
            if(i%2==0) pos=(i+num2)%n;
            else pos=(i+num1)%n; if(pos==0) pos=n;
            ans[pos]=i;
        }
        for(int i=1;i<=n;i++) printf("%d ",ans[i]);
        printf("
    ");
        return 0;
    }
  • 相关阅读:
    改变传统电视对客厅文化的影响
    移动终端三分天下 何与争峰
    全球移动IM应用的迅猛发展前景
    电子医疗的发展和实现
    poj 1523(无向图求割点)
    poj 3255(次短路)
    poj 2125
    poj 3204
    图的连通度问题的求法(转)
    poj 3308
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5904912.html
Copyright © 2011-2022 走看看