UVA 10193 Java

import java.util.*;
import static java.lang.System.*;

public class main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int cases = Integer.parseInt(sc.nextLine());	
    for(int i = 0; i < cases; i++)
    {
    	int num1 = Integer.parseInt(sc.nextLine(), 2);
    	int num2 = Integer.parseInt(sc.nextLine(), 2);
    	while(num2 != 0)
    	{
    		int temp = num2;
    		num2 = num1 % num2;
    		num1 = temp;
    	}
    	if(num1 != 1)
    		System.out.printf("Pair #%d: All you need is love!\r\n", i + 1);
    	else
    		System.out.printf("Pair #%d: Love is not all you need!\r\n", i + 1);
    }
  }
};

留言

這個網誌中的熱門文章

C# 井字遊戲