結果

問題 No.1455 拡張ROTN
コンテスト
ユーザー lloyz
提出日時 2022-02-08 22:05:27
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 889 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 360 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 15,484 KB
最終ジャッジ日時 2026-03-08 21:56:11
合計ジャッジ時間 3,711 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import string
alphs = list(string.ascii_lowercase)
Alphs = list(string.ascii_uppercase)
T = "CpCzNkSuTbEoA"

S = list(input())
n = int(input())

m = len(S)
ANS = []
for i in range(m):
    if ord('0') <= ord(S[i]) <= ord('9'):
        num = ord('9') - ord(S[i]) + 1
        if n >= num:
            cnt = n - num
            for s in T:
                if s.islower():
                    ANS.append(alphs[(ord(s) - ord('a') + cnt) % 26])
                elif s.isupper():
                    ANS.append(Alphs[(ord(s) - ord('A') + cnt) % 26])
        else:
            cnt = n
            ANS.append(str(int(S[i]) + cnt))
    else:
        cnt = n
        s = S[i]
        if s.islower():
            ANS.append(alphs[(ord(s) - ord('a') + cnt) % 26])
        elif s.isupper():
            ANS.append(Alphs[(ord(s) - ord('A') + cnt) % 26])
print(''.join(ANS))
0