/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
for (BigInteger a
= start, b
=start
; a.
compareTo(limit
) <= 0 && b.
compareTo(limit
) <= 0;) {
int comparacao = zap1.add(soma1).compareTo(zap2.add(soma2));
if (comparacao
== 0 && zap1.
compareTo(BigInteger.
ZERO) != 0 && zap2.
compareTo(BigInteger.
ZERO) != 0) { }
if (comparacao <= 0) {
zap1 = zap1.add(n2.multiply(a)); // formula(1) progressiva
}
else {
zap2 = zap2.add(n4.multiply(b)); // formula(2) progressiva
}
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLm1hdGguQmlnSW50ZWdlcjsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgkJQmlnSW50ZWdlciBzdGFydCA9IG5ldyBCaWdJbnRlZ2VyKCIxIik7CgkJQmlnSW50ZWdlciBsaW1pdCA9IG5ldyBCaWdJbnRlZ2VyKCIxMCIpOwoJCUJpZ0ludGVnZXIgemFwMSA9IG5ldyBCaWdJbnRlZ2VyKCIwIik7CgkJQmlnSW50ZWdlciB6YXAyID0gbmV3IEJpZ0ludGVnZXIoIjAiKTsKCQlCaWdJbnRlZ2VyIG4yID0gbmV3IEJpZ0ludGVnZXIoIjIiKTsgLy8gZm9ybXVsYSgxKSBwcm9ncmVzc2l2YQoJCUJpZ0ludG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