Day11 - Q - A Multiplication Game HDU - 1517

题目链接

本题很像bash博弈,但又有些许不同,因为这里是乘法,我们可以列出前几项可能

若n=2-9,那么first可以一次取完

若n=10-18,无论first怎么取,second都能一次取完

若n=19-162,那么无论second怎么取,first都能一次取完

若n=163-324 second一定可以取完

以此类推,类似bash博弈,每一组必胜必败态交换的距离为18的倍数,那么就将n/=18直到n<=18,然后判断即可

#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL; void run_case() {
double n;
while(cin >> n) {
while(n > ) n /= ;
if(n <= ) cout << "Stan wins.\n";
else cout << "Ollie wins.\n";
}
} int main() {
ios::sync_with_stdio(false), cin.tie();
//int t; cin >> t;
//while(t--)
run_case();
cout.flush();
return ;
}
上一篇:ICG游戏:证明,先手不是必胜就是必败。


下一篇:使用 git 进行项目管理(只管理代码,不管理项目配置)