1.

import java.io.*;
import java.util.*;


/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 10193 - All you need is Love
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1134
*
* @author Weigl Joseph
* @author Müller Thomas
* @version 1.0, -/-/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.100
*/


public class Main {

public static void main(String[] args) throws NumberFormatException, IOException {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int count = Integer.parseInt(br.readLine());

for (int i = 0; i < count; i++) {

int s1 = Integer.parseInt(br.readLine(), 2);
int s2 = Integer.parseInt(br.readLine(), 2);

if (ggT(s1, s2))
System.out.printf("Pair #%d: All you need is love!\n", i+1);
else
System.out.printf("Pair #%d: Love is not all you need!\n", i+1);

}
}

/*static int convertToDez(int a) {

int v = 1;
int sum = 0;
while (a > 0) {
int rest = a % 10;
sum += v * rest;
v *= 10;
a /= 10;
}
return sum;
}*/

static boolean ggT(int a, int b) {
boolean retval = false;
while (b != 0) {
int h = a % b;
a = b;
b = h;
}
if (a > 1)
retval = true;
return retval;
}
}

2.



---------------------------------------------------

1.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 10193 All you need is Love
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1134
*
* @author Bastian Hoecker
* @author Philipp Hauck Thalheim
* @version 1.0, 03/30/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.104
*/

public class Main {

public static int ggt2(int a, int b) {
int h = 0;
while (b != 0) {
h = a % b;
a = b;
b = h;
}
return a;
}

/**
* @param args
*/
public static void main(String[] args) throws IOException {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int number = Integer.parseInt(br.readLine());

for (int i = 0; i < number; i++) {

int fValue = 0;
int sValue = 0;

fValue = Integer.parseInt(br.readLine(), 2);
sValue = Integer.parseInt(br.readLine(), 2);

int b = ggt2(fValue, sValue);

if (b > 1)
System.out.printf("Pair #%d: All you need is love!\n", i + 1);
else
System.out.printf("Pair #%d: Love is not all you need!\n",
i + 1);

}

}

}


----------------------------------------------------------------

1.

/**
* ACM Training 2010
* ACM Problem #10193 - All You Need Is Love
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1134
*
* @author Felix Dietrich
* @version 1.0, 04/09/2010
*
* Methode: GCD
* Status : Accepted
* Runtime: 1.832
*/

import java.util.*;

public class Main
{
/**
* Greatest common divider of two numbers.
* @param a
* @param b
* @return gcd
*/
static int gcd(int a, int b)
{
if(a == 0)
return b;
while(b != 0)
if (a > b)
a = a - b;
else
b = b - a;
return a;
}

public static void main(String... strs)
{
Scanner sc = new Scanner(System.in);

int testcases = sc.nextInt();

for(int i=0; i<testcases; i++)
{
int s1 = sc.nextInt(2);
int s2 = sc.nextInt(2);

int a = gcd(s1,s2);

System.out.print(String.format("Pair #%d: ", i+1));
System.out.println(a != 1 ? "All you need is love!" : "Love is not all you need!");
}
}
}

2.

**
 *
 * Problem #10193 - All You Need Is Love
 * Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&page=show_problem&problem=1134

 *
 * @author Mariya Vlaseva
 *
 * Status : Accepted
 * Runtime: 1.816
 */

import java.util.*;

public class Main
{   
    public static void main(String... strs)
    {
        Scanner sc = new Scanner(System.in);

        //Anzahl Eingaben
        int count = sc.nextInt();
        //jede 2 Zeilen durchlaufen und vergleichen
        for(int i=0; i<count; i++)
        {
            int line1 = sc.nextInt(2);
            int line2 = sc.nextInt(2);

           
            int a = gcd(line1,line2);
           
            System.out.print(String.format("Pair #%d: ", i+1));
            System.out.println(a != 1 ? "All you need is love!" : "Love is not all you need!");

        }
    }
   
    static int gcd(int a, int b)
    {
        if(a == 0)
           return b;
        while(b != 0)
            if (a > b)
               a = a - b;
            else

               b = b - a;
        return a;
    }
}