結果

問題 No.18 うーさー暗号
ユーザー skyline
提出日時 2020-02-02 13:29:18
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,078 bytes
コンパイル時間 1,958 ms
コンパイル使用メモリ 74,296 KB
実行使用メモリ 55,820 KB
最終ジャッジ日時 2024-09-18 20:38:11
合計ジャッジ時間 4,196 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 12
権限があれば一括ダウンロードができます

ソースコード

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