Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.math.BigInteger;
- import java.util.*;
- public class Main {
- public static BigInteger max(BigInteger x, BigInteger y) {
- return x.compareTo(y) > 0 ? x : y;
- }
- public static void main(String args[]) {
- try (PrintWriter out = new PrintWriter(System.out);) {
- Scanner in = new Scanner(System.in);
- BigInteger w = in.nextBigInteger();
- BigInteger h = in.nextBigInteger();
- BigInteger n = in.nextBigInteger();
- BigInteger two = new BigInteger("2");
- BigInteger l = BigInteger.ONE;
- BigInteger r = n.multiply(max(w, h));
- BigInteger x = w.multiply(h).multiply(n);
- while (l.compareTo(r) < 0) {
- BigInteger m = l.add(r).divide(two);
- BigInteger width = m.divide(w);
- BigInteger height = m.divide(h);
- BigInteger num = width.multiply(height);
- if (m.multiply(m).compareTo(x) < 0 || num.compareTo(n) < 0)
- l = m.add(BigInteger.ONE);
- else
- r = m;
- }
- out.print(r.toString());
- } catch(Exception e) {
- System.out.println("Exception: " + e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement