Submission details
Task:Alien Invasion II
Sender:pierog
Submission time:2020-09-19 13:43:18 +0300
Language:Java
Status:READY
Result:
Test results
testverdicttime
#1--details
#2--details
#3--details

Code

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Optional;

public class Aliens {

    private static BigInteger getInput() {
        try (BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) )) {
            return new BigInteger(reader.readLine());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        var input = getInput();
        var alien = new Aliens(input);
        var result = alien.find();

        System.out.println(result.result);
        System.out.println(result.proof.a + " " + result.proof.b);
    }

    public static class SecondLine {
        BigInteger a;
        BigInteger b;

        SecondLine(BigInteger a, BigInteger b) {
            this.a = a;
            this.b = b;
        }
    }

    public static class AlienResult {
        BigInteger result;
        SecondLine proof;

        AlienResult(BigInteger result, SecondLine proof) {
            this.result = result;
            this.proof = proof;
        }
    }

    private BigInteger input;

    public Aliens(BigInteger input) {
        this.input = input;
    }

    private Optional<SecondLine> findDivision(BigInteger num) {
        var half = num.divide(BigInteger.TWO);
        for (BigInteger i = BigInteger.TWO; i.compareTo(half) == -1; i = i.add(BigInteger.ONE)) {
            if (num.mod(i).equals(BigInteger.ZERO)) {
                return Optional.of(new SecondLine(i, num.divide(i)));
            }
        }
        return Optional.empty();
    }

    public AlienResult find() {
        var result = findDivision(this.input);
        if (result.isPresent()) {
            return new AlienResult(this.input, result.get());
        }

        for (int i = 1; i < 99999; i++) {
            var newInput = new BigInteger(i + this.input.toString());
            result = findDivision(newInput);
            if (result.isPresent()) {
                return new AlienResult(newInput, result.get());
            }
        }
        return null;
    }
}

Test details

Test 1

Verdict:

input
2368469234876449

correct output
22368469234876449
3 7456156411625483

user output
(empty)

Test 2

Verdict:

input
292929292929292929292929292931

correct output
129292929292929292929292929293...

user output
(empty)

Test 3

Verdict:

input
292929292929292929292929292979

correct output
129292929292929292929292929297...

user output
(empty)