Created
March 1, 2015 06:20
-
-
Save takashima0411/2754569066019dc544a4 to your computer and use it in GitHub Desktop.
高橋くんと文字列圧縮(http://abc019.contest.atcoder.jp/tasks/abc019_2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class Main { | |
private static final Pattern pattern = Pattern.compile("([a-z])\\1*"); | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
String org = sc.next(); | |
Matcher matcher = pattern.matcher(org); | |
while(matcher.find()){ | |
String matched = matcher.group(); | |
System.out.print(matched.charAt(0) + "" + matched.length()); | |
} | |
System.out.println(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment