結果

問題 No.1020 Reverse
ユーザー n_gojo
提出日時 2020-04-13 14:07:11
言語 Java
(openjdk 23)
結果
AC  
実行時間 874 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 3,653 ms
コンパイル使用メモリ 75,244 KB
実行使用メモリ 64,552 KB
最終ジャッジ日時 2024-09-24 20:21:25
合計ジャッジ時間 14,301 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No1020 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String str = sc.next();
        char[] c = str.toCharArray();
        for(int i=0;i<n;i++) {
            if(i<(n-k+1)) {
                System.out.print(c[i+k-1]);
            }else{
                if((n-k)%2==1){
                    System.out.print(c[i-(n-k+1)]);
                }else{
                    System.out.print(c[n-i-1]);
                }
            }
        }
        System.out.println("");
    }
}
0