結果

問題 No.18 うーさー暗号
ユーザー takutakutakutaku
提出日時 2020-09-16 14:22:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,414 bytes
コンパイル時間 2,263 ms
コンパイル使用メモリ 73,912 KB
実行使用メモリ 56,200 KB
最終ジャッジ日時 2023-09-04 03:29:41
合計ジャッジ時間 5,457 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,336 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) {
	    
	    // 入力値を取得
		Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        
        // 入力文字列を1文字ずつの配列にする
        // アルファベットの配列を準備する
        String[] s = str.split("",0);
        String[] alphabet = {"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"};
        String[] result = new String[s.length];
        
        for(int i = 0; i < s.length; i++) {
            
            for(int j = 0; j < alphabet.length; j++) {
                
                // アルファベットの配列と照合して要素番号を取得する
                if(s[i].equals(alphabet[j])) {
                    int n = j;
                    n = n - i - 1;
                    
                    // 要素番号をずらしたアルファベットを配列に格納する
                    if(n < 0) {
                        while(n < 0){
                            n = 25 + n - 1;    
                        }
                        
                    }
                    result[i] = alphabet[n];
                }
            }
        }
        
        // 出力する
        for(int i = 0; i < result.length; i++) {
            System.out.print(result[i]);
        }
	}
}
0