Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Proba {
  4. public static void main(String[] args) {
  5.  
  6. Scanner sc = new Scanner(System.in);
  7.  
  8. int count = Integer.parseInt(sc.nextLine());
  9.  
  10. for (int i = 1; i <= count; i++) {
  11. String input = sc.nextLine();
  12.  
  13. int index = input.indexOf(" ");
  14.  
  15. long first = Long.parseLong(input.substring(0, index));
  16. long second = Long.parseLong(input.substring(index + 1));
  17. long sum = 0;
  18. long greater = 0;
  19.  
  20. greater = Math.max(first, second);
  21.  
  22. while (greater != 0) {
  23. sum += greater % 10;
  24. greater /= 10;
  25. }
  26.  
  27. System.out.println(Math.abs(sum));
  28. }
  29.  
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement