結果

問題 No.18 うーさー暗号
ユーザー kitamoto0407kitamoto0407
提出日時 2023-03-26 05:19:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 68 ms / 5,000 ms
コード長 1,372 bytes
コンパイル時間 2,638 ms
コンパイル使用メモリ 74,648 KB
実行使用メモリ 53,716 KB
最終ジャッジ日時 2023-10-19 11:10:07
合計ジャッジ時間 4,195 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
51,640 KB
testcase_01 AC 58 ms
53,688 KB
testcase_02 AC 68 ms
52,588 KB
testcase_03 AC 62 ms
52,600 KB
testcase_04 AC 60 ms
52,584 KB
testcase_05 AC 61 ms
53,688 KB
testcase_06 AC 61 ms
53,716 KB
testcase_07 AC 60 ms
53,708 KB
testcase_08 AC 62 ms
53,712 KB
testcase_09 AC 60 ms
53,712 KB
testcase_10 AC 61 ms
52,584 KB
testcase_11 AC 60 ms
53,676 KB
testcase_12 AC 61 ms
53,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;

// 処理
final class Process {
    private final String S;
    
    Process(final String S) {
        this.S = S;
    }
    
    // 結果を出力
    final void printResult(final PrintWriter printWriter) throws IOException {
        // 65: A, 90: Z
        
        for(int s = 0; s < S.length(); s++) {
            int charCode = (int)S.charAt(s) - (s + 1);
            if(charCode < 65) {
                while(charCode < 65) {
                    charCode += 26;
                }
            }
            
            printWriter.print((char)charCode);
        }
        printWriter.println();
    }
}

public class Main {
    public static void main(final String[] args) throws IOException {
        final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        final PrintWriter    printWriter    = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

        // 入力
        final String S = bufferedReader.readLine().trim();
        
        // Process クラスで処理を行う
        final Process process = new Process(S);
        process.printResult(printWriter);
        
        // 各ストリームを閉じる
        // 出力ストリームを閉じるときに標準出力に文字を出力する
        bufferedReader.close();
        printWriter.close();
    }
}
0