HDU-5050 Divided Land (二进制求GCD)】的更多相关文章

Divided Land Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 123    Accepted Submission(s): 64 Problem Description It’s time to fight the local despots and redistribute the land. There is a rect…
题意  给你两个二进制数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…
题目要求就是做求两个二进制数的gcd,如果是用java的话,这题很简单.但也可以用C++做,只能先给自己留下这个坑了,还在研究c++的做法. import java.math.BigInteger; import java.util.Scanner; /** * Created by emerald on 8/14/15. * */ public class Main { public static void main(String []args) { Scanner in = new Scan…
题目大意:将两个二进制数的GCD用二进制数表示出来. 题目分析:这道题可以用java中的大数类AC. 代码如下: import java.io*; import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String agrs[]){ Scanner sc=new Scanner(System.in); int T=sc.nextInt(); for(in…
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. As the mayor, you must segment the land into multiple squares of equal s…
http://acm.hdu.edu.cn/showproblem.php?pid=5050 题目大意: 给定一个矩形的长和宽,把这个矩形分成若干相等的正方形,没有剩余.求正方形的边长最长是多少. 解题思路: 这道题是“pick定理”的一个变种(不知道是pick定理,也可以退出结论).由定理是求矩形的长和宽最大公约数.但是这道题,输入的数是二进制, 输出也是二进制,二进制数的大小为2^1000,所以是大数的算法.java有大数的处理. 1 import java.math.BigInteger;…
题意:给定大数A和B,求gcd.所有数字都是二进制. 思路:先输入字符串,再转化为大数,然后用大数的gcd函数,最后转化为字符串输出. 利用字符串和大数转化的时候可以声明进制,就很舒服的完成了进制转化. import java.math.BigInteger; import java.util.Scanner; import java.io.*; /* @author nimphy @create 2019-11-06-12:50 about: */public class Main { sta…
Divided Land Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 56    Accepted Submission(s): 27 Problem Description    It’s time to fight the local despots and redistribute the land. There is a r…
了校赛,还有什么途径可以申请加入ACM校队?  覆盖的面积 Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4823    Accepted Submission(s): 2398 Problem Description 给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积.   Input 输入数据的第一行是一个正整数T(1…
[洛谷P1029]最大公约数与最小公倍数问题 Description 输入二个正整数x0,y0(2<=x0<100000,2<=y0<=1000000),求出满足下列条件的P,Q的个数 条件:1.P,Q是正整数;2.要求P,Q以x0为最大公约数,以y0为最小公倍数. 试求:满足条件的所有可能的两个正整数的个数. 输入格式:二个正整数x0,y0 输出格式:一个数,表示求出满足条件的P,Q的个数 Solution 1.由最大公约数的定义我们得到:存在k1,k2∈R,使P=k1x0,Q…