浙江财经大学第14届校赛 D (Disport with Jelly) 博弈



【博弈】

题意:  知道L,R 和x    明确知道x的位置,  两个人 谁去到x 谁就lose

   选择

k  >x   R=K-1  

k  <x   L=k+1

k =x  lose 


必输的 状态为   1,2,3   x=2 时  夹击 状态,     1,2,3,4,5  x=3 时  夹击状态

必赢  1,2    x=1 | x=2       1,2,3,4    无论x= 多少 都是必赢

当L,R 放大时  都可以 归结到上述情况, 故  可发现 当 L,R 长度为奇数 时 中间状态必lose  其余一定win


【code】

#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int t;
    scanf("%d",&t);
    int cot=0;
    while(t--)
    {
        int l,r,x;
        scanf("%d %d %d",&l,&r,&x);
        if((l-r+1)%2==0)
        {
            printf("Case #%d: Alice\n",++cot);
        }
        else
        {
            if((l+r)/2==x)
                printf("Case #%d: Bob\n",++cot);
            else
                printf("Case #%d: Alice\n",++cot);
        }
    }
    return 0;
}

    

123

posted @ 2018-03-24 20:52  Sizaif  阅读(176)  评论(0编辑  收藏  举报