51nod1072 威佐夫游戏

来源:互联网 发布:淘宝 企业店铺 编辑:程序博客网 时间:2024/05/16 19:33
#include <cstdio>#include <cmath>#include <iostream>using namespace std;typedef long long LL;int a,b;/*威佐夫博弈博弈黄金分割理论如果a == k,则为后手赢,否则先手赢(奇异局)*/int main(){    int t;    scanf("%d", &t);    while (t--)    {        scanf("%d%d", &a, &b);        if (a > b)//交换        {            a ^= b;            b ^= a;            a ^= b;        }        int m = b - a;        int k = (int)(m * (1 + sqrt(5)) / 2.0);        printf("%c\n", a == k ? 'B' : 'A');    }    return 0;}
原创粉丝点击