結果

問題 No.18 うーさー暗号
ユーザー skylineskyline
提出日時 2020-02-02 13:16:30
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,096 bytes
コンパイル時間 2,145 ms
コンパイル使用メモリ 75,440 KB
実行使用メモリ 57,800 KB
最終ジャッジ日時 2023-10-19 00:41:36
合計ジャッジ時間 4,691 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
57,444 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = Character.getNumericValue('A');
    public static int MAX_CODE = Character.getNumericValue('Z');
    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);
            if (code > 0) {
                sb.append(Character.toChars(MIN_CODE + code - 1));
            } else {
                code %= CHAR_NUM;
                sb.append(Character.toChars(MAX_CODE - code));
            }
        }
        this.result = sb.toString();
    }
    
    public String result() {
        return this.result;
    }
}
0