結果

問題 No.18 うーさー暗号
ユーザー l1267976
提出日時 2017-03-07 13:40:13
言語 Java
(openjdk 23)
結果
AC  
実行時間 155 ms / 5,000 ms
コード長 660 bytes
コンパイル時間 2,965 ms
コンパイル使用メモリ 76,152 KB
実行使用メモリ 55,272 KB
最終ジャッジ日時 2024-07-07 06:26:59
合計ジャッジ時間 5,480 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No18 {

    static final String ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String result = "";

        for (int i = 0; i < s.length(); i++) {
            int codeId = ALPHABETS.indexOf(s.charAt(i));

            int decodeId = (codeId - (i + 1)) % ALPHABETS.length();

            if (decodeId < 0) {
                decodeId += ALPHABETS.length();
            }

            result += ALPHABETS.charAt(decodeId);
        }

        System.out.println(result);

        sc.close();
    }

}
0