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

Compiler report

input/new2.java:1: error: class new1 is public, should be declared in a file named new1.java
public class new1 {
       ^
input/new2.java:4: error: cannot find symbol
		Scanner scam = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class new1
input/new2.java:4: error: cannot find symbol
		Scanner scam = new Scanner(System.in);
		                   ^
  symbol:   class Scanner
  location: class new1
3 errors

Code

public class new1 {

	public static void main(String[] args) {
		Scanner scam = new Scanner(System.in);
		String sc = scam + "*";
      	String n = "";
		String s = "";
		String fin = "";
		String[] arr = sc.split("");
		for(int i = 0; i < arr.length; i++)
        {
          	if(arr[i] == "*"){
              	int nn = Integer.parseInt(n);
				for(int j = 0; j < nn; j++){
					fin += s;
				}
              	break;
        	}else if(isNumericRegex(arr[i])){
				n += arr[i];
            }else if(!isNumericRegex(arr[i]) && isNumericRegex(arr[i+1])){
				int nn = Integer.parseInt(n);
				for(int j = 0; j < nn; j++){
					fin += s;
				}
              	
			} else {
				s += arr[i];
			}
		}
		System.out.println(fin);
	}
	
	public static boolean isNumericRegex(String str) {
		return str.matches("-?\\d+");
	}	
}