
 
 
 
1 import re 2 while True: 3 try: 4 5 s = input() 6 ss = '' 7 8 for i in s: 9 if re.search('[A-Z]', i): 10 if 'A' <= i < 'Z': 11 ss += chr(ord(i) - 1).lower() 12 elif i == 'Z': 13 ss += 'a' 14 15 elif re.search('[a-z]', i): 16 if 'a' <= i < 'z': 17 ss += chr(ord(i) + 1).upper() 18 elif i == 'z': 19 ss += 'A' 20 21 elif re.search('[0-9]', i): 22 if '0' <= i < '9': 23 ss += str(int(i) + 1) 24 elif i == '9': 25 ss += '0' 26 27 elif re.search('[^0-9a-zA-z]', i): 28 ss += i 29 30 print(ss) 31 32 except: 33 break
 
1 d = '' 2 for i in string_: 3 if i.isalpha(): 4 if i == 'z': 5 c = 'A' 6 elif i == 'Z': 7 c = 'a' 8 else: 9 c = ord(i) + 1 10 if c > 97: # a 的assi是97 11 c = chr(c).upper() 12 else: 13 c = chr(c).lower() 14 d += c 15 elif i.isdigit(): 16 if i == "9": 17 c = "0" 18 else: 19 c = int(i) + 1 20 d += str(c) 21 return d 22 23 ############################################################################# 24 25 def check(a,b): 26 L1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" 27 L2 = "BCDEFGHIJKLMNOPQRSTUVWXYZAbcdefghijklmnopqrstuvwxyza1234567890" 28 result = "" 29 if b == 1: 30 for i in a: 31 result += L2[L1.index(i)] 32 elif b == -1: 33 for i in a: 34 result += L1[L2.index(i)] 35 return result 36 37 while True: 38 try: 39 print(check(input(),1)) 40 print(check(input(), -1)) 41 42 except: 43 break 44 45 46 ############################################################################# 47 code1 = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") 48 code2 = list("BCDEFGHIJKLMNOPQRSTUVWXYZAbcdefghijklmnopqrstuvwxyza") 49 code3 = list("0123456789") 50 code4 = list("1234567890") 51 52 def encrypt(strings): 53 output = "" 54 for i in strings: 55 if 'A' <= i <= 'z': 56 output += code2[code1.index(i)] 57 elif '0' <= i <= '9': 58 output += code4[code3.index(i)] 59 else: 60 output += i 61 return output 62 63 def decrypt(strings): 64 output = "" 65 for i in strings: 66 if 'A' <= i <= 'z': 67 output += code1[code2.index(i)] 68 elif '0' <= i <= '9': 69 output += code3[code4.index(i)] 70 else: 71 output += i 72 return output 73 74 while True: 75 try: 76 string1 = input() 77 string2 = input() 78 print(encrypt(string1)) 79 print(decrypt(string2)) 80 except: 81 break 82 83 ############################################################################# 84 inttab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" 85 outtab = "bcdefghijklmnopqrstuvwxyzaBCDEFGHIJKLMNOPQRSTUVWXYZA1234567890" 86 while True: 87 try: 88 pwd1 = input() 89 pwd2 = input() 90 print(pwd1.translate(pwd1.maketrans(inttab, outtab))) 91 print(pwd2.translate(pwd2.maketrans(outtab, inttab))) 92 except: 93 break 94 95 ############################################################################# 96 97 d = '' 98 for i in string_: 99 if i.isalpha(): 100 if i == 'z': 101 c = 'A' 102 elif i == 'Z': 103 c = 'a' 104 else: 105 c = ord(i) + 1 106 if c > 97: # a 的assi是97 107 c = chr(c).upper() 108 else: 109 c = chr(c).lower() 110 d += c 111 elif i.isdigit(): 112 if i == "9": 113 c = "0" 114 else: 115 c = int(i) + 1 116 d += str(c) 117 return d 118 119 ############################################################################# 120 d = '' 121 for i in string_: 122 if i.isalpha(): 123 if i == 'z': 124 c = 'A' 125 elif i == 'Z': 126 c = 'a' 127 else: 128 c = ord(i) + 1 129 if c > 97: # a 的assi是97 130 c = chr(c).upper() 131 else: 132 c = chr(c).lower() 133 d += c 134 elif i.isdigit(): 135 if i == "9": 136 c = "0" 137 else: 138 c = int(i) + 1 139 d += str(c) 140 return d 141 142 ################################################################# 143 while True: 144 try: 145 s1 = input() 146 s2 = input() 147 s1_new = '' 148 s2_new = '' 149 for i in s1: 150 if i.isupper(): 151 if i == 'Z': 152 s1_new += 'a' 153 else: 154 s1_new += chr(ord(i) + 1).lower() 155 elif i.islower(): 156 if i == 'z': 157 s1_new += 'A' 158 else: 159 s1_new += chr(ord(i) + 1).upper() 160 elif i.isdigit(): 161 s1_new += str(int(i) + 1)[-1] 162 else: 163 s1_new += i 164 print(s1_new) 165 166 for i in s2: 167 if i.isupper(): 168 if i == 'A': 169 s2_new += 'z' 170 else: 171 s2_new += chr(ord(i) - 1).lower() 172 elif i.islower(): 173 if i == 'a': 174 s2_new += 'Z' 175 else: 176 s2_new += chr(ord(i) - 1).upper() 177 elif i.isdigit(): 178 if i == '0': 179 s2_new += '9' 180 else: 181 s2_new += str(int(i) - 1) 182 else: 183 s2_new += i 184 print(s2_new) 185 186 except: 187 break 188 189 190 ########################################################### 191 for i in range(len(list1)): 192 if list1[i]>='a' and list1[i]<='y': 193 list1[i]=chr(ord(list1[i])-32+1) 194 continue 195 if list1[i]=='z': 196 list1[i]='A' 197 continue 198 if list1[i]>='A' and list1[i]<='Y': 199 list1[i]=chr(ord(list1[i])+32+1) 200 continue 201 if list1[i]=='Z': 202 list1[i]='a' 203 continue 204 if list1[i]>='0' and list1[i]<='8': 205 list1[i]=chr(ord(list1[i])+1) 206 continue 207 if list1[i]=='9': 208 list1[i]='0' 209 continue 210 return list1 211 212 def jiemi(list1): 213 for i in range(len(list1)): 214 if list1[i]>='b' and list1[i]<='z': 215 list1[i]=chr(ord(list1[i])-32-1) 216 continue 217 if list1[i]=='A': 218 list1[i]='z' 219 continue 220 if list1[i]>='B' and list1[i]<='Z': 221 list1[i]=chr(ord(list1[i])+32-1) 222 continue 223 if list1[i]=='a': 224 list1[i]='Z' 225 continue 226 if list1[i]>='1' and list1[i]<='9': 227 list1[i]=chr(ord(list1[i])-1) 228 continue 229 if list1[i]=='0': 230 list1[i]='9' 231 continue 232 return list1 233 s1=input() 234 s2=input() 235 print(''.join(jiami(list(s1)))) 236 print(''.join(jiemi(list(s2)))) 237 238 ########################################################## 239 #原始人方法,简单逻辑往里怼 240 #将一些特殊的转换提前存入字典,方便接下来进行映射解析 241 dictT={'z':'A','Z':'a','9':'0'} #加密用 242 dictrT={'A':'z','a':'Z','0':'9'} #解密用 243 s = input() 244 s_r = '' #用于存储加密输出 245 r='' #用于存储解密输出 246 rs = input() 247 for i in s: #加密过程,不解释。。应套逻辑 248 if i in dictT.keys(): #先从那几个特殊的下手排查 z Z 9 249 s_r+=(dictT[i]) 250 elif i.isdigit(): 251 s_r+=str((int(i)+1)) 252 elif i.islower(): 253 s_r+=(chr(ord(i.upper())+1)) 254 elif i.isupper(): 255 s_r+=(chr(ord(i.lower())+1)) 256 else: 257 s_r+=(i) 258 for j in rs: #解密过程,依然硬套逻辑 从特殊的开始反转 259 if j in dictrT.keys(): 260 r+=(dictrT[j]) 261 elif j.isdigit(): 262 r+=str((int(j)-1)) 263 elif j.islower(): 264 r+=(chr(ord(j.upper())-1)) 265 elif j.isupper(): 266 r+=(chr(ord(j.lower())-1)) 267 else: 268 r+=(j) 269 print(s_r) 270 print(r)

 
 
# str = input() # n = len(str) # list = [] # for i in range(0,n-1): # for j in range(1,n): # if str[j] == str[i] and str[i+1:j] == str[j-1:i:-1]: # list.append(len(str[i:j+1])) # print(max(list)) # # # ABBA ->4 # #ABBBA ->5 # #12HHHHA ->4 ############################################ # 从右到左,对每个字符进行遍历处理,并且每个字符要处理两次,因为回文子串有两种情况: # ABA型:只需要从当前字符向两边扩散,比较左右字符是否相等,找出以当前字符为中心的最长回文子串长度 # ABBA型:只需要从当前字符和下一个字符向两边扩散,比较左右字符是否相等,找出以当前字符和下一个字符为中心的最长回文子串长度 # 最后比对两种类型的长度,取自较长的长度 s = input() out = 0 for i in range(0, len(s)): # 双指针 k = i - 1 j = i + 1 len_ABA = 1 while k >= 0 and j < len(s): if s[k] == s[j]: k -= 1 j += 1 len_ABA += 2 else: break k = i j = i + 1 len_ABBA = 0 while k >= 0 and j < len(s): if s[k] == s[j]: k -= 1 j += 1 len_ABBA += 2 else: break now_len = max(len_ABA, len_ABBA) if out < now_len: out = now_len print(out) ############################################## while 1: try: a=input() # 设置初始步长 bc=0 # 逆序比较 if a==a[::-1]: print(len(a)) else: # 不断增加步长,比较回文 #每次增加步长,循环查找有没有比这个步长更长的回文,如果有,继续找,直到找完所有的回文为止 for i in range(len(a)): # 优先查看两个增加两个长度的回文是否存在 if i-bc>=1 and a[i-bc-1:i+1]==a[i-bc-1:i+1][::-1]: bc+=2 # 如果增加两个长度的没找到,再查看两个增加一个长度的回文是否存在 elif i-bc>=0 and a[i-bc:i+1]==a[i-bc:i+1][::-1]: bc+=1 print(bc) except: break ############################################ str_input = input() if str_input == str_input[::-1]: print(len(str_input)) else: data_list = [] for i in range(len(str_input) - 1): for j in range(1, len(str_input)): if str_input[i] == str_input[j] and str_input[i + 1:j] == str_input[j - 1:i:-1]: data_list.append(len(str_input[i:j + 1])) print(max(data_list)) ########################################################### str = input() n = len(str) list = [] # range和字符串[0:3]取值都是最后一位不取值 for i in range(0, n - 1): for j in range(1, n): # 首先判定截取字符串的第一个特性,首位位置的字符相同, # 第二个特性,从左到右取数和从右到左取数,完全对称 if str[j] == str[i] and str[i + 1:j] == str[j - 1:i:-1]: list.append(len(str[i:j + 1])) # print(list) print(max(list)) ################################################ def expand(s, i, j): while i >= 0 and j < len(s) and s[i] == s[j]: i -= 1 j += 1 return i + 1, j - 1 while True: try: s = input() max_lens = 0 for i in range(len(s)): l1, r1 = expand(s, i, i) l2, r2 = expand(s, i, i + 1) if r1 - l1 + 1 > max_lens: max_lens = r1 - l1 + 1 if r2 - l2 + 1 > max_lens: max_lens = r2 - l2 + 1 print(max_lens) except: break ############################################################ str1 = input() list1 = [] n = 1 for i in str1[1:-1]: a = 1 b = 0 c = 1 d = 0 while True: try: if str1[n - c] == str1[n + c]: a = a + 2 c = c + 1 elif str1[n - d] == str1[n + d + 1]: b = b + 2 d = d + 1 else: list1.append(a) list1.append(b) n = n + 1 break except: list1.append(a) list1.append(b) break ###################################### import sys # 对字符串中的每一个字符遍历,首先判断是奇数回文串还是偶数回文串,再向两边拓展,判断并记录回文串的长度 def action(mm): maxx = 0 for i in range(1, len(mm) - 1): if mm[i] == mm[i - 1]: j = 1 while i + j <= len(mm) - 1 and i - 1 - j >= 0: if mm[i + j] == mm[i - 1 - j]: if maxx < 2 * j + 2: maxx = 2 * j + 2 j += 1 else: break if mm[i] == mm[i + 1]: j = 1 while i + 1 + j <= len(mm) - 1 and i - j >= 0: if mm[i + 1 + j] == mm[i - j]: if maxx < 2 * j + 2: maxx = 2 * j + 2 j += 1 else: break if mm[i] == mm[i + 1] and mm[i] == mm[i - 1]: j = 1 while i + 1 + j <= len(mm) - 1 and i - 1 - j >= 0: if mm[i + 1 + j] == mm[i - 1 - j]: if maxx < 2 * j + 3: maxx = 2 * j + 3 j += 1 else: break if mm[i] != mm[i + 1] and mm[i] != mm[i - 1]: j = 1 while i + j <= len(mm) - 1 and i - j >= 0: if mm[i + j] == mm[i - j]: if maxx < 2 * j + 1: maxx = 2 * j + 1 j += 1 else: break print(maxx) for i in sys.stdin: action(i.strip("\n"))

 
 
1 #我的 2 def funX(s): 3 4 l1=[] 5 #print(s) 6 ss='' 7 for i in s: 8 a=str(bin(int(i)))[2:].zfill(8) 9 # print(a) 10 l1.append(a) 11 12 b = ''.join(l1) 13 print(int(b,2)) 14 15 16 def funY(s2): 17 b = bin(int(s2)) 18 b=b[2:].zfill(32) 19 #print(b[2:].zfill(32)) 20 n =f'{int(b[:8],2)}.{int(b[8:16],2)}.{int(b[16:24],2)}.{int(b[24:],2)}' 21 print(n) 22 23 while True: 24 try: 25 s = input().split('.') 26 funX(s) 27 s2 = input() 28 funY(s2) 29 30 except: 31 break 32 33 34 ###################################################### 35 def func(lst): 36 s="" 37 for i in lst: 38 s+=i.replace('0b','').zfill(8) 39 print(int(s,2)) 40 41 42 def fc(s2): 43 s = bin(int(s2)) 44 s=s.replace('0b','').zfill(32) 45 n = f'{int(s[:8],2)}.{int(s[8:16],2)}.{int(s[16:24],2)}.{int(s[24:],2)}' 46 print(n) 47 while 1: 48 try: 49 s = [bin(int(i)) for i in input().split('.')] 50 func(s) 51 s2 = input() 52 fc(s2) 53 except: 54 break
 
1 import re 2 def change_ipaddr(ip): 3 ip = ip.split(".") 4 res = '' 5 for i in ip: 6 i = bin(int(i))[2:].rjust(8,'0') 7 res +=i 8 return int(res,2) 9 10 def change_number(number): 11 ip_list = [] 12 data = bin(int(number))[2:].rjust(32,'0') 13 data = re.findall(r'.{8}',data) 14 for i in data: 15 ip_list.append(str(int(i,2))) 16 return '.'.join(ip_list) 17 while True: 18 try: 19 num = change_ipaddr(input()) 20 ip = change_number(input()) 21 print(num) 22 print(ip) 23 except: 24 break 25 ################################################### 26 def ip2num(ip): 27 temp = ip.split('.') 28 num = 0 29 num = sum([int(s)*(256**(len(temp)-i-1)) for i,s in enumerate(temp)]) 30 return num 31 32 def num2ip(num): 33 num = int(num) 34 temp = [] 35 i = 3 36 while (i >= 0): 37 quo, num = divmod(num, 256**i) 38 temp.append(quo) 39 i -= 1 40 ip = '.'.join([str(i) for i in temp]) 41 return ip 42 43 while True: 44 try: 45 ip = input() 46 num = input() 47 48 print(ip2num(ip)) 49 print(num2ip(num)) 50 except Exception: 51 break

 
 
#1/首先生成正常字母顺序表 l = [] for i in range(26): l.append(chr(ord('a')+i)) while True: try: key,s = input(),input() new = [] """ 2/其次生成密匙""" for i in key: if i not in new: new.append(i) for i in l: if i not in new: new.append(i) """ 3/此时已经建立建立了新的密匙,如何与正常字母顺序表进行对照, 这里可以用一个python3中的zip方法,生成字典表 """ m = dict(zip(l,new)) res = [] for i in s: res.append(m[i]) print(''.join(res)) except: break ####################################################33 while True: try: list_c=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] # 初始字母表 list_b=list(input())# 关键字 list_d=sorted(set(list_b),key=list_b.index)# 关键字剔除重复项 list_out1=list(input())# 需被翻译项 list_out2=''# 翻译结果 for i in range(len(list_c)): if list_c[i] not in list_d: list_d+=list_c[i] #制作密码本 for i in range(len(list_out1)): for j in range(len(list_c)): if list_c[j] in list_out1[i]: list_out2+=list_d[j]# 嵌套循环加密加密 print(list_out2)# 输出结果 except: break ################################################################# letterlst = [] for i in range(26): letterlst.append(chr((ord("a") + i))) while True: try: key, encodestr = input(), input() newkey = [] for str1 in key: if str1 not in newkey: newkey.append(str1) for str1 in letterlst: if str1 not in newkey: newkey.append(str1) encodeDic = {} for i in range(len(newkey)): encodeDic[letterlst[i]] = newkey[i] newencodestr = "" for str1 in encodestr: newencodestr += encodeDic[str1] print(newencodestr) except: break ################################################################# while True: try: key = input().upper() string = input() alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' encrypted_map = [] res = '' for i in range(len(key)): if key[i] not in encrypted_map: encrypted_map.append(key[i]) for j in alpha: if j not in encrypted_map: encrypted_map.append(j) for k in string: if k.islower(): res += encrypted_map[alpha.index(k.upper())].lower() else: res += encrypted_map[alpha.index(k.upper())] print(res) except: break ###################################################################### while True: try: a = input().lower() original_code = input() a = list(dict.fromkeys(a)) b = [chr(i) for i in range(ord('a'),ord('z')+1,1)] c = b.copy() for i in a: c.remove(i) code = a + c translate_code = [] for j in original_code: translate_code.append(code[b.index(j)]) print(''.join(translate_code)) except: break ###################################################################### while True: try: str1 = input() str2 = input() str3 = sorted(map(str,set(str1)), key=str1.index) for i in range(26): if chr(ord('a')+i) not in str3: str3 += chr(ord('a')+i) for i in str2: a = ord(i) - ord('a') print(str3[a], end='') except: break ################################################## def quchong(key): ll = '' for i in key: if i not in ll: ll += i return ll def cankao(key): ss = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' mm = quchong(key) for s in ss: if s.upper() not in mm.upper(): mm += s # print("ss",ss) # print("mm",mm) return [ss,mm] def zhuanhaun(next,key): oo = '' for n in next: if n.islower(): ## 判断是小写 oo += cankao(key)[1][cankao(key)[0].find(n.upper())].lower() elif n.isupper(): # 判断是大写 oo += cankao(key)[1][cankao(key)[0].find(n)] else: oo += n print(oo) while True: try: key = input() next = input() zhuanhaun(next,key) except: break
 
key = input() mi = input() # 准备26个小写字母 list1 = [] for i in range(26): list1.append(chr(ord('a')+i)) print(list1) # 筛选key中的字母(主要是筛选不重复的) list2 = [] for i in key: if i not in list2: list2.append(i) print(list2) # 把其余的字母放顺序进来 for i in list1: if i not in list2: list2.append(i) # 根据输入的数据在26个英文字母的列表中找到位置 list3 = [] for i in range(len(mi)): for j in range(len(list1)): if mi[i] == list1[j]: list3.append(j) print(list3) # 根据位置输出结果 for i in list3: print(list2[i], end='') """ 输入: nihao ni 输出: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] ['n', 'i', 'h', 'a', 'o'] [13, 8] le """

 
n = 1 h = float(input()) s = [] h1=0 while n <= 5: h1 = h/2**n # 反弹的高度 s.append(h1) # print(s) n += 1 # print(n) # print(s[:4]) #计算第五次落地的路程,就要去掉第五次落地后反弹的高度 # print(2*sum(s[0:4])+h) #去掉了最后一个反弹的高度0.03125 # print(h1) print(format(2*sum(s[0:4])+h, '.3f')) # 通过规律算出来的,正好是前4次相加并加上初始值 print(format(h1, '.5f')) # format方法是保留小数点多少位 #################################################### def run(heigh, m, n): res1 = heigh tmp = heigh for i in range(n - 1): tmp = tmp * m res1 += tmp * 2 res2 = heigh * (m ** n) return res1, res2 heigh = int(input()) res1, res2 = run(heigh, 0.5, 5) print(res1) print(res2) ############################################3 s = int(input()) a = 0 f = s g = s for i in range(4): # 计算相加 g = g / 2 a += g for i in range(5): # 计算第五次 f = f / 2 print(format(a * 2 + s, '.3f')) # 通过规律算出来的,正好是前4次相加并加上初始值 print(format(f, '.5f')) # format方法是保留小数点多少位 ################################################################## while True: try: Hight = int(input()) # 第一次落下的高度 N = 1 # 球谈起的次数 Maxs = 5 NewHight = Hight # 每次落下时的新高度 Counts = 0 # 球经过的总长度 while N <= Maxs: # 循环次数小于等于总共弹起的次数 Counts += 1.5 * NewHight # 经过画图推理,每次都是落下时的1.5倍 NewHight = 0.5 * NewHight # 每次落下的心高度,都是上一次高度的一半 if N == Maxs: # 因为每次都是算了弹起的过程,而题目只要求统计第N次谈起时的总长度,如果是落下时则不需要减 Counts -= NewHight # 把总长度减去第N+1次落下时的高度 N += 1 print(Counts) print(NewHight) except: break

 
 
n = int(input()) mList = list(map(int, input().split())) xList = list(map(int, input().split())) lst = [] print(mList) print(xList) for i in range(n): lst+=[mList[i]]*xList[i] #这里没有想到要用列表的链接 print(lst) #所有的法码 weights = {0} #这个重量的组合 for a in lst: for b in list(weights): weights.add(a+b) print(len(weights)) print(weights) ##################################################### while True: try: n = int(input()) mList = list(map(int, input().split())) xList = list(map(int, input().split())) lst = [] for i in zip(mList, xList): lst += [i[0]] * i[1] weights = {0} for i in lst: for j in list(weights): weights.add(i+j) print(len(weights)) except: break ################################################################### n = int(input()) m = list(map(int, input().split())) x = list(map(int, input().split())) map_ = [[m[i] * j for j in range(x[i]+1)] for i in range(n)] # print(map_) if n == 1: print(len(map_[0])) else: r = set(map_[0]) # 这里如果使用列表,会内存超限 i = 1 while i < n: r2 = set() for j in r: for k in map_[i]: r2.add(j + k) r |= r2 i += 1 print(len(set(r))) ###################################################################
 
mList = (map(int, input().split())) print(mList) """ 输入:3 4 3 输出:<map object at 0x00000000028A4C10> """ mList = list(map(int, input().split())) print(mList) """ 输入:3 4 3 输出:[3, 4, 3] """
 
                    
                     
                    
                 
                    
                 

 
         
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号