andy6804tw
7/15/2016 - 10:49 AM

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=23&problem=2133&mosmsg=Submission+received+

import java.util.Scanner;
 
public class test {
 
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Scanner scn=new Scanner(System.in);
  while(scn.hasNext()){
   int n=scn.nextInt();
   if(n==0)break;
   String str=scn.next();
   char arr[]=str.toCharArray();
   if(n==1){
    for(int i=arr.length-1;i&gt=0;i--){
     System.out.print(arr[i]);
    }
    System.out.println();
   }
   else{
    n=arr.length/n;
   for(int i =n-1;i&ltarr.length;i+=n){
    for(int j=0;j<n;j++)
     System.out.print(arr[i-j]);
   }
   System.out.println();
  }
  }
 
 }
 
}
 
/* 
    題目:Q10055: Hashmat the brave warrior
    作者:1010
    時間:西元 2016 年 6 月 */