What are the two test cases that are failing? Will you be able to share them?
Two test cases are failing. Would like to know what are they?
@namanchauhan8998_5ae10b27a67dbd45 Since your input can be very very large so use long instead of int to store your answer and you will pass the testcases. So change datatype of βnβ and βvarβ to long datatype(Remember to chang sc.nextInt() to sc.nextLong())Your Corrected code is :
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn=new Scanner(System.in);
long n= scn.nextLong();
if (n == 1 || n == 2)
System.out.println(-1);
else if (n % 2 == 0)
{
// Calculating for even case
long var = 1 * n * n / 4;
System.out.print(var - 1+ " ");
System.out.print(var + 1 +" ");
}
else if (n % 2 != 0)
{
long var = 1 * n * n + 1;
System.out.print(var / 2 - 1 + " ");
System.out.print(var / 2 + " ");
}
}
}
Thank you so much for the response. This makes sense.
I hope Iβve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.