Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.util.Scanner;
- public class FromLeftToTheRight {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < n; i++) {
- BigInteger leftNum = scanner.nextBigInteger();
- BigInteger rightNum = scanner.nextBigInteger();
- BigInteger num;
- if (leftNum.compareTo(rightNum) > 0) {
- num = leftNum;
- } else {
- num = rightNum;
- }
- int totalDigitSum = 0;
- num = num.abs();
- while(num.intValue() != 0){
- totalDigitSum += num.remainder(BigInteger.valueOf(10)).intValue();
- num = num.divide(BigInteger.valueOf(10));
- }
- System.out.println(totalDigitSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement