Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
71264 胡海峰老师 11加密规则 Python3 Wrong Answer 33 MS 3796 KB 1406 2024-04-21 15:11:50

Tests(0/10):


Code:

def encrypt_password(password): # 将密码转换为字符串 password_str = str(password) # 1. 加密后第一个字符为密码第一个数字所对应的大写字母 encrypted_first_char = chr(int(password_str[0]) + ord('A') - 1) # 2. 加密后第二个字符按照密码第二个数字的奇偶性进行处理 encrypted_second_char = password_str[1] if int(password_str[1]) % 2 != 0 else int(password_str[1]) // 2 # 3. 加密后第三个字符则为密码前三个数字相加的个位数字 encrypted_third_char = str(sum(map(int, password_str[:3])) % 10) # 4. 加密后第四个字符即为密码第四个数字本身 encrypted_fourth_char = password_str[3] # 5. 加密后第五个字符则为'乐'(le)字拼音中,每一个字符(小写)所对应的ASCII相加再加上第五位密码的所得值的十位 encrypted_fifth_char = str((ord('l') + ord('e') + int(password_str[4]) // 10) % 10) # 6. 加密后第六个字符则是自己全部六个密码数字相加的个位 encrypted_sixth_char = str(sum(map(int, password_str)) % 10) # 返回加密后的字符串 return encrypted_first_char + str(encrypted_second_char) + encrypted_third_char + encrypted_fourth_char + encrypted_fifth_char + encrypted_sixth_char # 测试 print(encrypt_password(input())) # 输出: B16411


Run Info:

------Input------
115209
------Answer-----
B17208
------Your output-----
A17298