package lab8;

import java.util.Scanner;

public class Task4 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        // ===== Timus 2066 — Simple Expression =====
        System.out.println("Task 1 (Timus 2066)");
        System.out.println("Enter three integers a, b and c:");

        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        int min = a + b + c;
        min = Math.min(min, a * b + c);
        min = Math.min(min, a + b * c);
        min = Math.min(min, a * (b + c));
        min = Math.min(min, (a + b) * c);
        min = Math.min(min, a * b * c);

        System.out.println("Minimum value: " + min);

        // ===== Timus 1209 — 1, 10, 100, 1000… =====
        System.out.println();
        System.out.println("Task 2 (Timus 1209)");
        System.out.println("Enter number n:");

        long n = in.nextLong();

        long k = (long) ((Math.sqrt(8 * n - 7) - 1) / 2);
        long value = k * (k + 1) / 2 + 1;

        if (value == n) {
            System.out.println("Result: 1");
        } else {
            System.out.println("Result: 0");
        }

        in.close();
    }
}
