結果
問題 | No.1455 拡張ROTN |
ユーザー |
![]() |
提出日時 | 2021-04-13 08:57:15 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 1,601 bytes |
コンパイル時間 | 1,983 ms |
コンパイル使用メモリ | 77,652 KB |
実行使用メモリ | 37,400 KB |
最終ジャッジ日時 | 2024-06-29 02:57:05 |
合計ジャッジ時間 | 4,391 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
import java.io.*;import java.util.*;public class Main {public static void main(String[] args) throws Exception {Scanner sc = new Scanner();String s = sc.next();long n = sc.nextLong();for (int i = 0; i < Math.min(10, n); i++) {s = change(s);}n = Math.max(0, n - 10);n %= 26;for (int i = 0; i < n; i++) {s = change(s);}System.out.println(s);}static String change(String s) {StringBuilder ans = new StringBuilder();for (char c : s.toCharArray()) {if (c >= 'a' && c <= 'z') {ans.append((char)((c - 'a' + 1) % 26 + 'a'));} else if (c >= 'A' && c <= 'Z') {ans.append((char)((c - 'A' + 1) % 26 + 'A'));} else if (c == '9') {ans.append("CpCzNkSuTbEoA");} else {ans.append((char)(c + 1));}}return ans.toString();}}class Scanner {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));StringTokenizer st = new StringTokenizer("");public Scanner() throws Exception {}public int nextInt() throws Exception {return Integer.parseInt(next());}public long nextLong() throws Exception {return Long.parseLong(next());}public String next() throws Exception {if (!st.hasMoreTokens()) {st = new StringTokenizer(br.readLine());}return st.nextToken();}}