O. Big Add and Multiply – Codeforces Problem Solution in Java

Disclaimer: Make sure you tried enough before checking the solution

The problem is easier to solve using java as java has big integer package. But in c++, you will have to do it manually. The solution for both c++ and java is below:

Problem: https://codeforces.com/group/MWSDmqGsZm/contest/223338/problem/O

//Using Java

import java.math.BigInteger;
import java.util.Scanner;

public class OBigAddandMultiply {

    public static void main(String[] args) {

        try (Scanner scanner = new Scanner(System.in)) {
            String num = scanner.next();
            BigInteger bigInteger1 = new BigInteger(num);
            BigInteger bigInteger2 = new BigInteger("9999");
            System.out.println(bigInteger1.add(bigInteger2));
            System.out.println(bigInteger1.multiply(bigInteger2));
        }
    }

}

Assiut University Training – Newcomers Solution Math – Geometry

Leave a Comment