CSES - Datatähti 2017 alku - Results
Submission details
Task:Pakkaus
Sender:planckcons
Submission time:2016-10-03 19:20:10 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

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

Code

import java.util.*;
import java.util.stream.Collectors;

public class Pakkaus {
    
    public static void main(String[] args) {
        Scanner scam = new Scanner(System.in);
        //String scam = "12fe4he";
        String sc = scam + "*";
      	String n = "";
        String s = "";
        String fin = "";
        String[] arr = sc.split("");
        
        for(int i = 1; i < arr.length; i++)
        {
            if(Num(arr[i]) && !Num(arr[i-1]))
            {
                arr[i-1] += "*";
            }
        }
        
        sc = Arrays.stream(arr).collect(Collectors.joining(""));
        arr = sc.split("");
        for(int i = 0; i < arr.length; i++)
        {
            if(Num(arr[i])) {
                n += arr[i];
            } else if(!Num(arr[i]) && !"*".equals(arr[i])) {
                s += arr[i];
            } else if("*".equals(arr[i])) {
                int nn = Integer.parseInt(n);
                for(int j = 0; j < nn; j++){
                        fin += s;
                }
                s = "";
                n = "";
                System.out.println(fin);
            }
            System.out.println(n);
            System.out.println(s);
        }
    System.out.println(fin);
    }

    public static boolean Num(String str) {
            return str.matches("-?\\d+");
    }	
}