結果

問題 No.18 うーさー暗号
ユーザー hnthnt
提出日時 2016-04-30 02:46:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 160 ms / 5,000 ms
コード長 701 bytes
コンパイル時間 3,027 ms
コンパイル使用メモリ 74,764 KB
実行使用メモリ 56,412 KB
最終ジャッジ日時 2023-09-21 12:17:06
合計ジャッジ時間 5,698 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
55,704 KB
testcase_01 AC 109 ms
55,740 KB
testcase_02 AC 116 ms
55,988 KB
testcase_03 AC 151 ms
56,412 KB
testcase_04 AC 142 ms
56,296 KB
testcase_05 AC 143 ms
56,056 KB
testcase_06 AC 155 ms
56,056 KB
testcase_07 AC 154 ms
56,212 KB
testcase_08 AC 160 ms
56,204 KB
testcase_09 AC 147 ms
56,172 KB
testcase_10 AC 115 ms
55,884 KB
testcase_11 AC 115 ms
56,272 KB
testcase_12 AC 143 ms
56,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class no18 {
	public static void main(String[] args) {
		String[] az = {"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"};
		Scanner sc = new Scanner(System.in);
		Map<String,Integer> map = new HashMap<String,Integer>();
		for (int i = 0; i < az.length; i++) {
			map.put(az[i],i);
		}
		String s = sc.next();
		int N = 0;
		int azidx = 0;
		for (int i = 0 ; i < s.length(); i++) {
			azidx = map.get(String.valueOf(s.charAt(i))) - (i + 1) % 26;
			if (azidx < 0) {
				N = 26 + azidx;
			} else {
				N = azidx;
			}
			System.out.print(az[N]);
		}
	}
}
0