首页 > 其他 > 详细

51nod 1185 || 51nod 1072 威佐夫博弈

时间:2017-08-14 20:39:00      阅读:377      评论:0      收藏:0      [点我收藏+]

贴个模板:平常的跟高精度java的;

int:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define LL long long
#define pi (4*atan(1.0))
#define eps 1e-14
#define bug(x)  cout<<"bug"<<x<<endl;
const int N=1e6+10,M=1e6+10,inf=1e9+10;
const LL mod=1e9+7;

int main()
{
    double k=(sqrt(5.0)+1)/2;
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        if(a>b)swap(a,b);
        int x=(b-a)*k;
        if(x==a)printf("B\n");
        else printf("A\n");
    }
    return 0;
}

 

java:

import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        BigInteger k=new BigInteger("16180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374");
        BigInteger p=new BigInteger("10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
        int T;
        T=cin.nextInt();
        while(T--!=0)
        {
            BigInteger nn=cin.nextBigInteger();
            BigInteger mm=cin.nextBigInteger();
            BigInteger n=nn.min(mm);
            BigInteger m=nn.max(mm);
            BigInteger j=m.subtract(n);
            j=j.multiply(k);
            j=j.divide(p);
            if(j.equals(n))
                System.out.println("B");
            else 
                System.out.println("A");
        }
    }
}

 

51nod 1185 || 51nod 1072 威佐夫博弈

原文:http://www.cnblogs.com/jhz033/p/7359989.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!