NP28. 密码游戏
描述
输入描述
输入一个四位数的整数。输出描述
输出破解后的密码,以四位数的形式。示例1
输入:
1234
输出:
6745
Python 解法, 执行用时: 13ms, 内存消耗: 3076KB, 提交时间: 2022-08-02
get_keys = input() def decode_num(x): return (x + 3) % 9 result = decode_num(get_keys % 100 - get_keys % 10) * 1000 + decode_num(get_keys % 10) * 100 + decode_num(get_keys // 1000) * 10 + decode_num(get_keys % 1000 - get_keys % 100) print("%04d" % result)
Python 解法, 执行用时: 13ms, 内存消耗: 3084KB, 提交时间: 2022-06-24
num=str(input()) list1=list(num) list1=[str((int(i)+3)%9) for i in list1] temp=list1[0] list1[0]=list1[2] list1[2]=temp temp=list1[1] list1[1]=list1[3] list1[3]=temp print("".join(list1))
Python 解法, 执行用时: 13ms, 内存消耗: 3112KB, 提交时间: 2022-06-14
num = int(input()) a = num//1000 #1 b = (num-a*1000)//100 #2 c = (num-a*1000-b*100)//10#3 d = (num-a*1000-b*100-c*10)#4 new_c = (a+3)%9 #4 new_d = (b+3)%9 #5 new_a = (c+3)%9 #6 new_b = (d+3)%9 #7 new_num = new_a*1000+new_b*100+new_c*10+new_d if new_a != 0: print(new_num) else: print('0' + str(new_b*100+new_c*10+new_d))
Python 解法, 执行用时: 14ms, 内存消耗: 3004KB, 提交时间: 2022-07-26
old_str = input() new = '' for i in str(old_str): i = (int(i)+3) % 9 new = new + str(i) first = new[0] second = new[1] third = new[2] four = new[3] new = third+four+first+second print(new)
Python 解法, 执行用时: 14ms, 内存消耗: 3048KB, 提交时间: 2022-06-11
x = str(raw_input()) y = "" for i in x: y = y + str((int(i) + 3) % 9) f = list(y) f[0], f[2] = f[2], f[0] f[1], f[3] = f[3], f[1] z = "" for j in range(len(f)): z = z + f[j] print(z)