CF777A题解

发布时间 2023-10-27 10:55:56作者: Kazdale
  • 分析

    发现操作 \(6\) 次后就会回到初状态,于是将状态打表,将 \(n\bmod6\) 即可。
  • 代码

#include <iostream>
using namespace std;
constexpr int MAXN(1000007);
int a[6][3] = {
	{0, 1, 2},
	{1, 0, 2},
	{1, 2, 0},
	{2, 1, 0},
	{2, 0, 1},
	{0, 2, 1}
};
int n, k; 
inline void read(int &temp) { cin >> temp; }
int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	read(n), read(k);
	cout << a[n % 6][k] << endl;
	return 0;
}