【循环节】 Codeforces Round #401 (Div. 2) A. Shell Game

容易发现存在循环节。

#include<cstdio>
using namespace std;
int n,x,a[3][6]={{0,1,2,2,1,0},{1,0,0,1,2,2},{2,2,1,0,0,1}};
int main()
{
	scanf("%d%d",&n,&x);
	for(int i=0;i<=2;++i)
	  if(a[i][n%6]==x)
	    {
	      printf("%d
",i);
	      return 0;
	    }
	return 0;
}
原文地址:https://www.cnblogs.com/autsky-jadek/p/6440232.html