結果

問題 No.18 うーさー暗号
ユーザー nullzinenullzine
提出日時 2017-01-11 16:29:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 1,055 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 72,132 KB
実行使用メモリ 58,444 KB
最終ジャッジ日時 2023-09-21 12:35:35
合計ジャッジ時間 4,317 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
53,844 KB
testcase_01 AC 111 ms
56,460 KB
testcase_02 AC 111 ms
56,268 KB
testcase_03 AC 142 ms
57,752 KB
testcase_04 AC 141 ms
55,908 KB
testcase_05 AC 141 ms
55,620 KB
testcase_06 AC 147 ms
57,968 KB
testcase_07 AC 149 ms
58,444 KB
testcase_08 AC 137 ms
57,668 KB
testcase_09 AC 148 ms
57,704 KB
testcase_10 AC 111 ms
55,624 KB
testcase_11 AC 111 ms
55,960 KB
testcase_12 AC 131 ms
55,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 * Created by nullzine on 2017/01/11.
 */
public class Main {

    public static void main(String[] args) {
        System.out.println(new Main().decode(new java.util.Scanner(System.in).nextLine()));
    }

    private String decode(String str) {
        StringBuilder ret = new StringBuilder();
        for (int i = 0; i < str.toCharArray().length; i++) {
            char c = str.charAt(i);
            for (int j = 0; j < i + 1; j++) {
                c--;
                if (c == '@') {
                    c = 'Z';
                }
            }
            ret.append(c);
        }
        return ret.toString();
    }

    private String encode(String str) {
        StringBuilder ret = new StringBuilder();
        for (int i = 0; i < str.toCharArray().length; i++) {
            char c = str.charAt(i);
            for (int j = 0; j < i + 1; j++) {
                c++;
                if (c == '[') {
                    c = 'A';
                }
            }
            ret.append(c);
        }
        return ret.toString();
    }

}
0