CSES - Datatähti 2017 alku - Results
Submission details
Task:Pakkaus
Sender:sp
Submission time:2016-10-04 22:02:54 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

input/Compresio12n.java:13: error: class, interface, or enum expected
    public static void main(String[] args) { 
                  ^
input/Compresio12n.java:15: error: class, interface, or enum expected
     String c = s.nextLine();
     ^
input/Compresio12n.java:16: error: class, interface, or enum expected
     int nb2 =c.length();
     ^
input/Compresio12n.java:17: error: class, interface, or enum expected
     String answer ="";
     ^
input/Compresio12n.java:18: error: class, interface, or enum expected
  while (nb2>0) {
  ^
input/Compresio12n.java:22: error: class, interface, or enum expected
       String d[] = c.split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
       ^
input/Compresio12n.java:23: error: class, interface, or enum expected
       int h=d[i].length();
       ^
input/Compresio12n.java:26: error: class, interface, or enum expected
        int x = Integer.parseInt(d[0]);
        ^
input/Compresio12n.java:27: error: class, interface, or enum expected
        c=c.substring...

Code

import java.util.Scanner;

/**
 *
 * @author Miro Petsalo
 */


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) { 
       Scanner s = new Scanner(System.in);
     String c = s.nextLine();
     int nb2 =c.length();
     String answer ="";
  while (nb2>0) {
     
      int i=0;
      
       String d[] = c.split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
       int h=d[i].length();
         
        
        int x = Integer.parseInt(d[0]);
        c=c.substring(h);
        while(x>0){
            answer = answer+d[i+1];
            x=x-1;
        }
    
     

 
       String d1[] = c.split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
       int h1=d[i+1].length();
      
         c=c.substring(h1);
        
        
       nb2 =c.length();
     
  }
      System.out.println(answer);   
    }