# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372255 | 2021-02-27T10:35:41 Z | kutbilim_one | Odd-even (IZhO11_oddeven) | Java 11 | 0 ms | 0 KB |
import java.util.*; import java.math.*; public class Main{ 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(); } }