HDU2897邂逅明下(博弈)

时间:2023-07-19 09:42:50

题目是说每次每个人可以取[p,q],而且是最后一个不得不取完的人输

这道题刚刚看别人过,还一直纠结感觉不会做,然后想到1+q的倍数,还是不会,想到p+q的倍数,却发现最后一个取的人是输的,然后就更加无奈了。果真还是不会博弈啊!!!!实在没办法了从1开始找必胜区间和必输区间,搞了个规律,然后把它过了,,,,

必胜态:[k*(p+q)+P+1,   (k+1)*(p+q)]

必输态:[k*(p+q)+1,       k*(p+q)+p  ]

可以看出必胜态的每个数都可以拿走一个数,是指减少到必输态中。

必输态中每个数不论是拿走[p,q]中的任意一个数都只能得到必胜态的某一个数。

HDU2897邂逅明下(博弈)

 #include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
#define mem0(a) memset(a,0,sizeof(a))
#define lson k<<1, L, mid
#define rson k<<1|1, mid+1, R typedef long long LL;
const double eps = 1e-;
const int MAXN = ;
const int MAXM = ; int main()
{
int n,p,q;
while(~scanf("%d%d%d", &n,&p,&q))
{
if(n%(q+p)== || n%(p+q)>=p+) printf("WIN\n");
else printf("LOST\n");
}
return ;
}