U35387 天才少年汪之茗对决爱因斯坦

· · 题解

天才少年汪之茗对决爱因斯坦题解
算法分析:博弈论
我的做法:
1个:先手赢
2个:先手赢
3个:后手赢
4个:先手赢
5个:先手赢
6个:后手赢
.
.
.
.
.
.
打表找规律~
得出AC程序:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
bool check(ll x)
{
    return !(x%3==0);
}
int main()
{
    scanf("%lld",&n);
    check(n)?printf("Zhiming Wang\n"):printf("Yinsitan Ai\n");
    return 0;
} 

当然~LJ的做法:
博弈论:
让当前局面变成自己必胜的局面
∵3个时后手赢
∴3+2^i时先手必胜
当且仅当个数n为三的倍数时,n无法分解成3+2^i的形式,则得出规律