【题解】老魔杖

题意

给定一些整数,都在 \([1, 4]\) 以内,每次操作可以把一个整数拆成两个 \([1, 3]\) 内的整数,或删掉 \(n \in [1, 4]\)\(n\),不能操作输,则问先手是否必胜。

\(a, b, c, d \le 10^{10000}\)

思路

这是一道找规律题。

可以对所有状态进行分类,记 \(u = (a + c) \bmod 2, v = (b + d) \bmod 3\)

\(u = v\) 必胜,证明需要对 \(8\) 种转移进行讨论,发现所有转移必定使 \(u = v\) 的转移到 \(u \ne v\),而 \(u \ne v\) 的必定可以通过一种转移转移到 \(u = v\)

Code

#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
using namespace std;
#define File(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
typedef long long ll;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	char getc () {return gc();}
	inline void flush () {fwrite (obuf, 1, oS - obuf, stdout); oS = obuf;}
	inline void putc (char x) {*oS ++ = x; if (oS == oT) flush ();}
	template <class I> inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
	template <class I> inline void print (I x) {if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while (x) qu[++ qr] = x % 10 + '0',  x /= 10;while (qr) putc (qu[qr --]);}
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
	int rdm2(){
		unsigned char s = 0;
		char ch;
		while(isspace(ch = gc()));
		do s = s * 10 + (ch - '0'); while(isdigit(ch = gc()));
		return s & 3;
	}
	int rdm3(){
		int s = 0;
		char ch;
		while(isspace(ch = gc()));
		do s = (s * 10 + (ch - '0')) % 3; while(isdigit(ch = gc()));
		return s;
	}
}
using io :: rdm3; using io :: print; using io :: rdm2; using io :: gi;
template<class T> void upmax(T &x, T y){x = x>y ? x : y;}
template<class T> void upmin(T &x, T y){x = x<y ? x : y;}

int main(){
	int T;
	gi(T);
	while(T--){
		int s = 0, t = 0;
		s += rdm2(); t += rdm3(); s += rdm2(); t += rdm3();
		if(s % 2 == t % 3) puts("0");
		else puts("1");
	}
	return 0;
}
posted @ 2020-03-27 20:04  RiverHamster  阅读(152)  评论(0编辑  收藏  举报
\