結果

問題 No.18 うーさー暗号
ユーザー ゆうP
提出日時 2017-11-05 01:41:59
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 497 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-07 06:39:34
合計ジャッジ時間 1,059 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# No.18 うーさー暗号
def main():
    s = input()
    ans = ''
    for idx, c in enumerate(s):
        # single byte code A:65, B:66, ... ,Y:89,Z:90
        shift_size = ((idx + 1) % 26)
        if (ord(c) - ord('A') - shift_size) >= 0:
            ans += chr(ord(c) - shift_size)
        else:
            ans += chr(ord('Z') + (ord(c) - ord('A') - shift_size) + 1)

    print(ans)


if __name__ == '__main__':
    main()

0