結果

問題 No.18 うーさー暗号
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-11 21:29:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 599 bytes
コンパイル時間 3,579 ms
コンパイル使用メモリ 72,860 KB
実行使用メモリ 55,932 KB
最終ジャッジ日時 2023-09-21 12:45:01
合計ジャッジ時間 4,844 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,932 KB
testcase_01 AC 121 ms
55,516 KB
testcase_02 AC 123 ms
55,644 KB
testcase_03 AC 126 ms
55,492 KB
testcase_04 AC 126 ms
55,524 KB
testcase_05 AC 125 ms
55,792 KB
testcase_06 AC 123 ms
55,656 KB
testcase_07 AC 125 ms
55,608 KB
testcase_08 AC 126 ms
55,624 KB
testcase_09 AC 127 ms
55,888 KB
testcase_10 AC 123 ms
55,460 KB
testcase_11 AC 124 ms
55,328 KB
testcase_12 AC 126 ms
55,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] sch = s.toCharArray();
    char[] ansch = new char[s.length()];
    char a = 'B' - 'A';
    char b = 'Z' - 'A';
    for(int i = 0; i < s.length(); i++) {
      char c = sch[i];
      int move = (i + 1) % 26;
      for(int j = 0; j < move; j++) {
        if(c == 'A') {
          c += b;
        } else {
          c -= a;
        }
      }
      ansch[i] = c;
    }
    String ans = new String(ansch);
    System.out.println(ans);
  }
}
0