Last active
December 23, 2018 08:41
-
-
Save yjfvictor/4b9bec2315ebdfb3b009 to your computer and use it in GitHub Desktop.
Divided Land http://acm.hdu.edu.cn/showproblem.php?pid=5050
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author 叶剑飞 | |
* @date 2014-10-03 | |
* @brief Divided Land | |
* @note http://acm.hdu.edu.cn/showproblem.php?pid=5050 | |
* @copyright To the extent possible under law, the author has dedicated all copyright | |
* and related and neighboring rights to this software to the public domain | |
* worldwide. This software is distributed without any warranty. | |
* You should have received a copy of the CC0 Public Domain Dedication along with | |
* this software. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>. | |
*/ | |
import java.io.*; | |
import java.util.*; | |
import java.math.BigInteger; | |
class Main | |
{ | |
public static void main(String [] args) | |
{ | |
BigInteger a, b, c; | |
int i, n; | |
Scanner cin = new Scanner(System.in); | |
n = cin.nextInt(); | |
for ( i = 1; i <= n; ++ i) | |
{ | |
a = new BigInteger(cin.next(), 2); | |
b = new BigInteger(cin.next(), 2); | |
c = a.gcd(b); | |
System.out.printf("Case #%d: %s", i, c.toString(2)); | |
System.out.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment