CSES - Datatähti 2019 alku - Results
Submission details
Task:Kolikot
Sender:EeliH
Submission time:2018-10-01 19:37:43 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

input/a.java:3: error: class Kolikot is public, should be declared in a file named Kolikot.java
public class Kolikot {
       ^
1 error

Code

import java.util.Scanner;

public class Kolikot {
    public static void main(String[] args) {
        long[] numbers = new long[44721];
        int length = 2;
        numbers[0] = 1;
        numbers[1] = 2;
        long number = Long.parseLong(new Scanner(System.in).nextLine());
        int currentIndex = 1;
        if(number == 1) {
            numbers[1] = 0;
            System.exit(0);
        }else if(number == 0) {
            System.out.println("0");
            System.exit(0);
        }else if(number == 2) {
            numbers[0] = 2;
            numbers[1] = 0;
            System.exit(0);
        }
        for(long i = 1; i < number - 2; i++) {
            if(currentIndex > -1) {
                numbers[currentIndex] += 1;
                currentIndex--;
            }else {
                currentIndex = length;
                System.arraycopy(numbers, 0, numbers, 1, length);
                length++;
                numbers[0] = 1;
            }
        }
        for(long num: numbers) {
            if(num == 0)
                break;
            System.out.print(num + " ");
        }
    }
}