import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
while(true){
StringTokenizer st=new StringTokenizer(br.readLine());
int n=Integer.parseInt(st.nextToken());
if(n==0){
break;
}
String temp=st.nextToken();
int length=temp.length()/n;
StringBuilder str=new StringBuilder();
for(int i=0,j=0;i<temp.length();i++){
str.append(temp.charAt(i));
if(j%length==length-1){
j=0;
sb.append(str.reverse());
str=new StringBuilder();
}else{
j++;
}
}
sb.append("\n");
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
while(true){
StringTokenizer st=new StringTokenizer(br.readLine());
int n=Integer.parseInt(st.nextToken());
if(n==0){
break;
}
String temp=st.nextToken();
int length=temp.length()/n;
StringBuilder str=new StringBuilder();
for(int i=0,j=0;i<temp.length();i++){
str.append(temp.charAt(i));
if(j%length==length-1){
j=0;
sb.append(str.reverse());
str=new StringBuilder();
}else{
j++;
}
}
sb.append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment