自己跟学校同学玩想到了一个巴什博弈变种
共有n个火柴,两人轮流取。
对于全局第k次取火柴操作,取的一方可以取1∼k个。
取到最后一个火柴的一方赢
自己试着证明了一下,但这里写起来太麻烦,思路也比较简单,递推就行。
然后写了这个代码看正确不,还有这个博弈叫什么,用ai搜没找到,主要是想出个题造数据给同学考下。
YES
是先手胜,反之后手胜
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long
#define putchar_unlocked putchar
inline int brand() {
return (rand() << 15) + rand();
}
inline bool gb(int x, int w) {
return x & (1 << (w - 1));
}
inline void wb(int& x, int w, bool z) {
if (z) {
x = x | (1 << (w - 1));
}
else {
x = x & ~(1 << (w - 1));
}
}
int _now = 1 << 16;
int _rma = 1 << 16;
char buff[1 << 16];
inline char getch() {
if (_now == _rma) {
if (_rma != 1 << 16)return EOF;
_rma = fread(buff, 1, _rma, stdin);
_now = 0;
}
return buff[_now++];
}
inline void write(int s, bool c = 1) {
if (!s) { if (c)putchar_unlocked('0'); }
else if (s < 0) putchar_unlocked('-'), write(-s / 10, 0);
else write(s / 10, 0), putchar_unlocked(s % 10 + '0');
}
inline void swrite(const char* in) {
while (*in != '\0')putchar_unlocked(*in++);
}
#define getch() getchar()
inline int read() {
int out = 0;
bool sf = 0;
char get = getch();
while (get < '0' || get > '9') {
if (get == '-')sf = 1;
get = getch();
}
while (get >= '0' && get <= '9')out *= 10, out += get - '0', get = getch();
return sf ? -out : out;
}
//---------------------------------------------------------------------------------------------------------------------------
//===========================================================================================================================
int t, n;
int get(int in) {
int out = (in + 1) * 2 + 4;
out *= in;
out /= 2;
return out + 1;
}
int reget(int in) {
double a = 1, b = 3, c = -in;
double d = b * b - 4 * a * c;
d = sqrt(d);
return (-b + d) / (2 * a);
}
signed main() {
t = read();
while (t--) {
n = read();
if (n == 1){
cout << "YES" << endl;
continue;
}
int sl = reget(n-2);
n -= get(sl);
if (n <= (sl + 2))cout << "NO" << endl;
else cout << "YES" << endl;
}
}