結果

問題 No.1455 拡張ROTN
ユーザー ntuda
提出日時 2025-07-03 21:29:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 82,656 KB
実行使用メモリ 54,200 KB
最終ジャッジ日時 2025-07-03 21:29:35
合計ジャッジ時間 2,660 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

L = "abcdefghijklmnopqrstuvwxyz"
U = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
key = "CpCzNkSuTbEoA"
K = "CpCzNkSuTbEoA"
Num = []
dicl = {}
dicu = {}
for i in range(26):
    dicl[L[i]] = i
    dicu[U[i]] = i
for i in range(26):
    Num.append(K)
    K2 = ""
    for s in K:
        if s.islower():
            K2 += L[(dicl[s] + 1) % 26]
        else:
            K2 += U[(dicu[s] + 1) % 26]
    K = K2
S = input()
N = int(input())
ans = []
for s in S:
    if s.isdecimal():
        s = int(s)
        if s + N < 10:
            ans.append(str(s + N))
        else:
            x = (s + N - 10) % 26
            ans.append(Num[x])
    elif s.islower():
        ans.append(L[(dicl[s] + N) % 26])
    else:
        ans.append(U[(dicu[s] + N) % 26])
print("".join(ans))
0