結果

問題 No.18 うーさー暗号
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-23 12:12:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 860 bytes
コンパイル時間 2,252 ms
コンパイル使用メモリ 72,612 KB
実行使用メモリ 49,376 KB
最終ジャッジ日時 2023-09-21 12:42:28
合計ジャッジ時間 3,742 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
48,996 KB
testcase_01 AC 44 ms
49,376 KB
testcase_02 AC 45 ms
49,088 KB
testcase_03 AC 48 ms
47,236 KB
testcase_04 AC 46 ms
49,156 KB
testcase_05 AC 47 ms
49,144 KB
testcase_06 AC 47 ms
49,332 KB
testcase_07 AC 47 ms
49,092 KB
testcase_08 AC 48 ms
49,196 KB
testcase_09 AC 48 ms
49,176 KB
testcase_10 AC 46 ms
49,176 KB
testcase_11 AC 46 ms
49,184 KB
testcase_12 AC 46 ms
49,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String S = reader.readLine();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < S.length(); i++) {
            int N = i + 1;
            builder.append(intToChar(charToInt(S.charAt(i)) - N));
        }
        System.out.println(builder.toString());
    }

    private static int charToInt(char c) {
        return (c - 'A');
    }

    private static char intToChar(int i) {
        i = (i % 26);
        if (i < 0) {
            return (char) ('Z' + i + 1);
        } else {
            return (char) ('A' + i);
        }
    }
}
0