結果

問題 No.1455 拡張ROTN
ユーザー lloyzlloyz
提出日時 2022-02-08 22:05:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 889 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 10,992 KB
実行使用メモリ 9,368 KB
最終ジャッジ日時 2023-09-05 22:34:45
合計ジャッジ時間 2,022 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,156 KB
testcase_01 AC 28 ms
9,220 KB
testcase_02 AC 27 ms
9,156 KB
testcase_03 AC 26 ms
9,248 KB
testcase_04 AC 27 ms
9,292 KB
testcase_05 AC 26 ms
9,172 KB
testcase_06 AC 27 ms
9,216 KB
testcase_07 AC 27 ms
9,220 KB
testcase_08 AC 27 ms
9,108 KB
testcase_09 AC 26 ms
9,164 KB
testcase_10 AC 27 ms
9,216 KB
testcase_11 AC 26 ms
9,160 KB
testcase_12 AC 26 ms
9,320 KB
testcase_13 AC 27 ms
9,208 KB
testcase_14 AC 27 ms
9,296 KB
testcase_15 AC 27 ms
9,176 KB
testcase_16 AC 26 ms
9,264 KB
testcase_17 AC 27 ms
9,368 KB
testcase_18 AC 27 ms
9,220 KB
testcase_19 AC 27 ms
9,296 KB
testcase_20 AC 26 ms
9,168 KB
testcase_21 AC 26 ms
9,296 KB
testcase_22 AC 26 ms
9,244 KB
testcase_23 AC 26 ms
9,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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