HDU 5050

http://acm.hdu.edu.cn/showproblem.php?pid=5050

大数gcd

import java.io.* ;
import java.math.* ;
import java.util.* ;
import java.text.* ;

public class Main
{
    public static void main(String[] args)
    {
        Scanner cin=new Scanner (new BufferedInputStream(System.in)) ;
        BigInteger A,B ;
        int t=cin.nextInt() ;
        for (int cas=1 ;cas<=t ;cas++)
        {
            A=cin.nextBigInteger(2) ;
            B=cin.nextBigInteger(2) ;
            System.out.print("Case #"+cas+": ") ;
            System.out.println(A.gcd(B).toString(2)) ;
        }
    }
}

时间: 2024-12-11 11:49:02

HDU 5050的相关文章

HDU 5050 Divided Land ( JAVA )

HDU 5050 - Chinese Girls' Amusement ( JAVA or 高精度 ) 题意不用再解释 做法是求两个二进制数的最大公约数字 然后以二进制输出 import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static PrintWriter out = new PrintWriter(new BufferedWriter( new OutputStrea

HDU 5050 Java 大数类+读入二进制

http://acm.hdu.edu.cn/showproblem.php?pid=5050 才知道 原来JAVA这么好用,连二进制都封装好了 in.nextBigInteger(2)  就是按二进制读入 当然a.gcd(b).toString(2)  是按二进制输出一个二进制String,  a,b是大数 另外,JAVA交代码原来是class Main import java.math.BigInteger; import java.util.Scanner; public class Mai

HDU 5050 Divided Land(最大公约数Java)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5050 Problem Description It's time to fight the local despots and redistribute the land. There is a rectangular piece of land granted from the government, whose length and width are both in binary form.

hdu 5050 Divided Land---2014acm上海赛区网络赛

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5050 Divided Land Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 115    Accepted Submission(s): 57 Problem Description It's time to fight the loc

hdu 5050 Divided Land

题目:本质是求两个数的最大公约数,java大数真好用 ^_^. import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { BigInteger TWO = BigInteger.valueOf(2); Scanner t = new Scanner(System.in); int cas = t.nextInt(); for

hdu 5050 Divided Land(JAVA高精度)

import java.util.Scanner; import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner cin=new Scanner(System.in); int T; T=cin.nextInt(); BigInteger a,b; for(int cas=1;cas<=T;cas++){ a=cin.nextBigInteger(2); b=ci

HDU 5050 Divided Land(进制转换)

题意  给你两个二进制数m,n   求他们的最大公约数  用二进制表示  0<m,n<2^1000 先把二进制转换为十进制  求出最大公约数  再把结果转换为二进制  数比较大要用到大数 import java.util.*; import java.math.*; public class wl6_9 { static BigInteger two = BigInteger.valueOf(2), one = BigInteger.ONE, zero = BigInteger.ZERO; s

HDU 5045 5047 5050 5053(上海网络赛E,F,I,L)

HDU 5045 5047 5050 5053 太菜了,名额差点没保住,吓尿..赶紧开刷树链抛分 5045:状压DP,压缩10个人,由于两个人不能差2以上,所以可以用01表示 5047:推推公式即可,每次交线多4条 5050:求GCD,用java大叔即可 5053:签到题 代码: 5045: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N

hdu 5030 Rabbit&#39;s String(后缀数组&amp;二分)

Rabbit's String Time Limit: 40000/20000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 288    Accepted Submission(s): 108 Problem Description Long long ago, there lived a lot of rabbits in the forest. One day, the