結果

問題 No.18 うーさー暗号
ユーザー a_tena_ten
提出日時 2016-03-10 23:20:01
言語 Python2
(2.7.18)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 278 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 6,500 KB
実行使用メモリ 6,096 KB
最終ジャッジ日時 2023-09-21 12:09:02
合計ジャッジ時間 1,282 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,028 KB
testcase_01 AC 11 ms
5,940 KB
testcase_02 AC 12 ms
6,032 KB
testcase_03 AC 13 ms
5,920 KB
testcase_04 AC 12 ms
5,988 KB
testcase_05 AC 13 ms
5,984 KB
testcase_06 AC 13 ms
6,060 KB
testcase_07 AC 12 ms
5,932 KB
testcase_08 AC 12 ms
5,916 KB
testcase_09 AC 13 ms
5,904 KB
testcase_10 AC 12 ms
5,900 KB
testcase_11 AC 12 ms
6,096 KB
testcase_12 AC 12 ms
5,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#coding:utf-8

from math import fabs

alp='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n=raw_input()

s=map(ord,n)

a=[]
for i in range(len(s)):
	diff=int(fabs((s[i]-(i+1)) - ord('A'))) % 26
	if ord('A') <= s[i]-(i+1):
		a.append(chr(s[i]-(i+1)))
	else:
		a.append(alp[-diff])

print ''.join(a)
0