結果

問題 No.18 うーさー暗号
ユーザー skylineskyline
提出日時 2020-02-02 13:38:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 1,068 bytes
コンパイル時間 2,861 ms
コンパイル使用メモリ 78,048 KB
実行使用メモリ 57,764 KB
最終ジャッジ日時 2023-10-19 00:47:11
合計ジャッジ時間 5,436 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
57,452 KB
testcase_01 AC 131 ms
57,264 KB
testcase_02 AC 134 ms
57,464 KB
testcase_03 AC 139 ms
57,684 KB
testcase_04 AC 136 ms
57,764 KB
testcase_05 AC 137 ms
57,672 KB
testcase_06 AC 137 ms
57,728 KB
testcase_07 AC 138 ms
57,596 KB
testcase_08 AC 138 ms
57,652 KB
testcase_09 AC 138 ms
57,612 KB
testcase_10 AC 132 ms
57,540 KB
testcase_11 AC 132 ms
57,328 KB
testcase_12 AC 137 ms
57,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    
    public static void main(String[] args) {
        
        No0018 no = new No0018();

        System.out.println(no.result());
        
    }
    
}

class No0018 {
    public static int MIN_CODE = "A".codePointAt(0);
    public static int MAX_CODE = "Z".codePointAt(0);
    public static int CHAR_NUM = MAX_CODE - MIN_CODE + 1;
    private String s;
    private String result;
    
    public No0018() {
        Scanner sc = new Scanner(System.in);
        this.s = sc.next();
        StringBuffer sb = new StringBuffer("");
        for (int i = 0; i < this.s.length(); i++) {
            int code = this.s.codePointAt(i) - MIN_CODE + 1;
            code = code - (i + 1);
            code %= CHAR_NUM;
            if (code > 0) {
                sb.append(Character.toChars(MIN_CODE + code - 1));
            } else {
                sb.append(Character.toChars(MAX_CODE + code));
            }
        }
        this.result = sb.toString();
    }
    
    public String result() {
        return this.result;
    }
}
0