Skip to content

Instantly share code, notes, and snippets.

@yjfvictor
Last active December 23, 2018 08:41
Show Gist options
  • Save yjfvictor/4b9bec2315ebdfb3b009 to your computer and use it in GitHub Desktop.
Save yjfvictor/4b9bec2315ebdfb3b009 to your computer and use it in GitHub Desktop.
/**
* @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