結果

問題 No.18 うーさー暗号
ユーザー eagleeagle
提出日時 2022-06-16 14:09:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 746 bytes
コンパイル時間 2,247 ms
コンパイル使用メモリ 74,552 KB
実行使用メモリ 41,880 KB
最終ジャッジ日時 2024-04-16 01:58:36
合計ジャッジ時間 5,219 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
40,056 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.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] moji = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
				'I', 'J', 'K', 'L', 'M', 'N',
				'O', 'P', 'Q', 'R', 'S', 'T', 'U',
				'V', 'W', 'X', 'Y', 'Z'
		};
		for(int i = 0; i < S.length(); i++) {
			char c = S.charAt(i);
			int idx = 0;
			for(int j = 0; j < moji.length; j++) {
				if(moji[j] == c) {
					idx = j;
					break;
				}
			}
			if(0 > idx - (i + 1)) {
				idx = (idx - (i + 1)) * (-1);
				idx = idx % moji.length;
			} else {
				idx = idx - (i + 1);
			}
			System.out.print(moji[idx]);
		}
		System.out.println();
	}
}
0