博弈论,可以证明,先手总是赢
一开始我不会,看了cf上国际友人的证明才明白(他用的是反证法):
Proof by contradiction :
Say the initial state is always a losing state. This means regardless of the number the first player picks , the second player ends up with a winning state (if not , the initial state would have been a winning state). Say the first player picks 1 and the second player ends up with {2,3,4,…,N} which is a winning state. Say the second player picks X now and provides the first player with state S (a losing state) , the first player could have just picked X and forced the second player to state S ( a losing state) which is a contradiction. Hence the first player always wins.
代码很容易:
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
template<typename T> void read(T &a)
{
a=0;
int f=1;
char c=getchar();
while(!isdigit(c))
{
if(c=='-')
{
f=-1;
}
c=getchar();
}
while(isdigit(c))
{
a=a*10+c-'0';
c=getchar();
}
a=a*f;
}
template <typename T> void write(T a)
{
if(a<0)
{
a=-a;
putchar('-');
}
if(a>9)
{
write(a/10);
}
putchar(a%10+'0');
}
template <typename T> void writeln(T a)
{
write(a);
puts("");
}
}
int main()
{
int n;
cin>>n;
while(n--)
{
int a,b;
cin>>a>>b;
if(b==0)
{
puts("Airborne wins.");
}
else
{
puts("Pagfloyd wins.");
}
}
}