import java.math.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.*;
public class Main {
public static void main(String args[])throws IOException
{
StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
in.nextToken();
int n = (int)in.nval;
in.nextToken();
int k = (int)in.nval;
in.nextToken();
String x = in.sval;
String sum="";
String sums="";
for(int t=0;t<n/k;t++)
{
if(t>0)
x = x.substring(1)+x.charAt(0);
sum=x.substring(0,k);
for(int i=k;i<n;i+=k)
{
if((x.substring(i,i+k)).compareTo(sum)>0)
{
sum = x.substring(i,i+k);
continue;
}
}
if(t==0)
sums = sum;
else{
if(sums.compareTo(sum)>0)
sums = sum;
}
}
out.print(sums);
out.flush();
}
}
看了看这道题java没有通过的,我不知道哪里出了问题-.-感觉思路应该没问题吧,巨佬们可以帮我看看嘛