結果

問題 No.1455 拡張ROTN
ユーザー tobusakanatobusakana
提出日時 2022-10-28 00:51:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 1,052 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 71,484 KB
最終ジャッジ日時 2023-09-18 19:04:20
合計ジャッジ時間 4,542 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,484 KB
testcase_01 AC 72 ms
71,100 KB
testcase_02 AC 77 ms
71,244 KB
testcase_03 AC 71 ms
70,940 KB
testcase_04 AC 70 ms
71,252 KB
testcase_05 AC 73 ms
71,408 KB
testcase_06 AC 72 ms
71,020 KB
testcase_07 AC 72 ms
70,924 KB
testcase_08 AC 73 ms
71,156 KB
testcase_09 AC 72 ms
71,056 KB
testcase_10 AC 73 ms
71,252 KB
testcase_11 AC 72 ms
71,244 KB
testcase_12 AC 71 ms
71,424 KB
testcase_13 AC 72 ms
71,128 KB
testcase_14 AC 72 ms
71,356 KB
testcase_15 AC 72 ms
71,072 KB
testcase_16 AC 72 ms
71,452 KB
testcase_17 AC 72 ms
71,332 KB
testcase_18 AC 73 ms
71,384 KB
testcase_19 AC 72 ms
71,368 KB
testcase_20 AC 71 ms
71,332 KB
testcase_21 AC 71 ms
71,332 KB
testcase_22 AC 73 ms
71,068 KB
testcase_23 AC 71 ms
71,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

S = readline().rstrip()
N = int(readline())

# 既に処理したことがあるものはdicに登録しておく
dic = {}

ans = []
def rotate_char(c, M):
  rot = M % 26
  if c.upper() == c: # 大文字の場合
    return chr((ord(c) - ord('A') + rot) % 26 + ord('A'))
  else:
    return chr((ord(c) - ord('a') + rot) % 26 + ord('a'))
  
# CpCzNkSuTbEoAを0~25回rotateすると何になるかを求めておく
bef = [""] * 26
T = "CpCzNkSuTbEoA"
for i in range(26):
  temp = []
  for t in T:
    temp.append(rotate_char(t, i))
  bef[i] = "".join(temp)
  
for s in S:
  if s in dic:
    ans.append(dic[s])
    continue
  if s.isdigit():
    # CpCzNkSuTbEoAになるまでに何回必要か
    to_T = 10 - int(s)
    if to_T > N: # CpCzNkSuTbEoAになれない
      ans.append(str(int(s) + N))
      continue
    rest = N - to_T # 残りの試行回数
    ans.append(bef[rest % 26])
  else:
    target = rotate_char(s, N)
    dic[s] = target
    ans.append(target)
    
print("".join(ans))  
  
  
  
  
0