UVA 10193 Java

  1. import java.util.*;
  2. import static java.lang.System.*;
  3.  
  4. public class main{
  5. public static void main(String[] args) {
  6. Scanner sc=new Scanner(System.in);
  7. int cases = Integer.parseInt(sc.nextLine());
  8. for(int i = 0; i < cases; i++)
  9. {
  10. int num1 = Integer.parseInt(sc.nextLine(), 2);
  11. int num2 = Integer.parseInt(sc.nextLine(), 2);
  12. while(num2 != 0)
  13. {
  14. int temp = num2;
  15. num2 = num1 % num2;
  16. num1 = temp;
  17. }
  18. if(num1 != 1)
  19. System.out.printf("Pair #%d: All you need is love!\r\n", i + 1);
  20. else
  21. System.out.printf("Pair #%d: Love is not all you need!\r\n", i + 1);
  22. }
  23. }
  24. };
  25.  

留言

這個網誌中的熱門文章

C# 井字遊戲