問題:http://codeforces.com/contest/25/problem/B
import java.util.Scanner; public class B { public static void main(String[] args) throws Exception{ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); String s = scan.next(); int a = s.length() % 2 < 1 ? 2 : 3; for(int i = 0; i < s.length() - a; i+=2){ System.out.print(s.substring(i,i+2)+"-"); } System.out.println(s.substring(s.length()-a,s.length())); } }