結果

問題 No.18 うーさー暗号
ユーザー koukonkokoukonko
提出日時 2015-12-07 12:01:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 102 ms / 5,000 ms
コード長 745 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 81,124 KB
実行使用メモリ 53,080 KB
最終ジャッジ日時 2023-09-21 12:01:02
合計ジャッジ時間 4,226 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
52,300 KB
testcase_01 AC 81 ms
52,520 KB
testcase_02 AC 79 ms
52,712 KB
testcase_03 AC 97 ms
53,080 KB
testcase_04 AC 80 ms
52,680 KB
testcase_05 AC 91 ms
52,836 KB
testcase_06 AC 86 ms
52,700 KB
testcase_07 AC 97 ms
52,812 KB
testcase_08 AC 99 ms
52,896 KB
testcase_09 AC 87 ms
52,792 KB
testcase_10 AC 80 ms
52,724 KB
testcase_11 AC 82 ms
52,512 KB
testcase_12 AC 102 ms
52,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));

		// 0x41 = A 0x5A = Z
		final char[] ALPHA = new char[26];
		for(int i = 0; i < 26; ++i){
			ALPHA[i] = (char) ('A' + i);
		}

		try {
			String line = buff.readLine();
			String ans = "";

			for(int i = 0; i < line.length(); ++i){
				int num = line.charAt(i) - 'A' - (i + 1);
				if(num < 0){
					num %= 26;
					num += 26;
				}
				if(num == 26){
					num %= 26;
				}
				ans += ALPHA[num];
			}
			System.out.println(ans);

		} catch (NumberFormatException e) {

		} catch (IOException e) {

		}
	}
}
0