51 nod 1072 威佐夫博弈

来源:互联网 发布:java cp classpath 编辑:程序博客网 时间:2024/06/02 00:56

http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1072

最简单的威佐夫博弈,直接上代码:

#include<iostream>#include<cmath>#include<stdio.h>#include<algorithm>#include<stack>#include<map>#include<string>#define maxn 1000000using namespace std;int main(){ long long n,a,b; scanf("%lld",&n);     while(n--)     {         scanf("%lld%lld",&a,&b);         if(a>b)            swap(a,b);         long long r=b-a;         r=(long long)r*((sqrt(5)+1)/2);            if(a==r)                printf("B\n");            else                printf("A\n");              //  cout<<r;     }}