結果

問題 No.18 うーさー暗号
ユーザー yshrnsmryshrnsmr
提出日時 2017-03-07 00:39:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 175 ms / 5,000 ms
コード長 656 bytes
コンパイル時間 2,338 ms
コンパイル使用メモリ 74,008 KB
実行使用メモリ 57,224 KB
最終ジャッジ日時 2023-09-21 12:38:46
合計ジャッジ時間 5,448 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
56,672 KB
testcase_01 AC 161 ms
56,672 KB
testcase_02 AC 163 ms
57,224 KB
testcase_03 AC 172 ms
57,036 KB
testcase_04 AC 172 ms
56,948 KB
testcase_05 AC 172 ms
56,980 KB
testcase_06 AC 174 ms
56,788 KB
testcase_07 AC 173 ms
56,704 KB
testcase_08 AC 175 ms
56,932 KB
testcase_09 AC 174 ms
56,724 KB
testcase_10 AC 162 ms
56,964 KB
testcase_11 AC 163 ms
56,604 KB
testcase_12 AC 174 ms
56,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        String result = "";

        for (int i = 0; i < s.length(); i++) {
            int idx1 = alphabets.indexOf(s.charAt(i));
            int key = i + 1;
            int idx2 = (idx1 - key) % alphabets.length();

            if (idx2 < 0) {
                idx2 += alphabets.length();
            }

            result += alphabets.charAt(idx2);
        }

        System.out.println(result);

        sc.close();
    }

}
0