zoukankan      html  css  js  c++  java
  • 51nod 1185 || 51nod 1072 威佐夫博弈

    贴个模板:平常的跟高精度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
    ");
            else printf("A
    ");
        }
        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");
            }
        }
    }
  • 相关阅读:
    KMP字符串查找
    基数排序
    二分查找来查找旋转数组
    通过前序(后序)+中序创建树
    二维数组找最大值
    用字符串的空格替换其他字符
    桶排序
    字符串的排列
    和为S的两个数字
    整数中1出现的次数(从1到n整数中1出现的次数)
  • 原文地址:https://www.cnblogs.com/jhz033/p/7359989.html
Copyright © 2011-2022 走看看