HDOJ2897 邂逅明下
这跟巴什博弈是一样的找出区间[1-p]必败 [p+1,p+q]必胜(取一个q,就能进入第一个区间) [p+q+1,2*p+q]必败,[2*p+q+1,2*p+2*q]必胜;
View Code
#include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #include<queue> #include<set> #include<map> #include<cstring> #include<vector> #include<string> #define LL long long using namespace std; int main( ) { int n,p,q; while( scanf( "%d %d %d",&n,&p,&q )==3 ) { n %= ( p + q ); if( n <= p && n != 0) puts( "LOST" ); else puts( "WIN" ); } //system( "pause" ); return 0; }