codeforces 777 A

三个盖子 

其中里面有一个下面有求

一个人移来移去

奇数次 0 1 换 偶数次 1 2 换

给你最后的位子移动的次数 问开始的位子 

 

显然这个题有循环结      6  

然后暴力一下  

#include <iostream>
#include<string.h>
#include<stdio.h>
using namespace std ;
#define LL long long

int z[3];

int main()
{
    int n,x;
    scanf("%d%d",&n,&x);
    n=n%6;
    int ok=0;

    for(int k=0;k<=2;k++)
    {
        memset(z,0,sizeof(z));
        z[k]=1;
        for(int i=1;i<=n;i++)
        {
            if(i%2==1)
                swap(z[0],z[1]);
            else
                swap(z[1],z[2]);
        }
        if(z[x]==1)
            ok=k;
    }
    printf("%d\n",ok);
    return 0 ;
}

 

posted on 2017-02-28 20:17  HelloWorld!--By-MJY  阅读(479)  评论(0编辑  收藏  举报

导航