# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372254 | kutbilim_one | Odd-even (IZhO11_oddeven) | Java | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import java.util.*;
import java.math.*;
public class IZHO{
public static void main(String args[]){
Scanner cin = new Scanner(System.in);
/// 2*n - floor( (1+ sqrt(8*n-7))/2 )
BigInteger n = cin.nextBigInteger();
BigInteger sqrtPart = n.multiply(BigInteger.valueOf(8)).subtract(BigInteger.valueOf(7)).sqrt().add(BigInteger.valueOf(1)).divide(BigInteger.valueOf(2));
BigInteger res = n.multiply(BigInteger.valueOf(2)).subtract(sqrtPart);
System.out.print(res);
cin.close();
}
}