tommy_txj
tommy_txj
全部文章
分类
归档
标签
去牛客网
登录
/
注册
tommy_txj的博客
全部文章
(共25篇)
题解 | #名字的漂亮度#
def nice(words): # 构造函数计算出漂亮值 # 实际上我们要求的是,‘abcda’中的字母的频数由大到小排列的向量x,与我们的系数向量的内积和 nice_list = sorted(list(range(1,27)),reverse=True) # 系数 x...
2022-12-19
0
209
题解 | #在字符串中找出连续最长的数字串#
while 1: try: a=input() aa = '' # 新建一个空字符,将字母换成任意标记,如英文逗号 for each in a: if each.isalpha(): a...
2022-12-19
0
392
题解 | #字符统计#
while True: try: a=input() s = sorted(set(a)) # 先升序排 ss = sorted(s,key=lambda x: a.count(x)*1000 - ord(x), reverse=True ) ...
2022-12-19
0
218
题解 | #查找两个字符串a,b中的最长公共子串#
while True: try: a=input() b=input() m = a if len(a)<len(b) else b # m 是短的字符,它的长度为下面的lm,将充当bp二维list的行数 n = b...
2022-12-17
0
253
题解 | #找出字符串中第一个只出现一次的字符#
while True: try: c=input() d={} # 作出字典,key为字符,v为频数 for i in c: if i not in d: d[i]=1 ...
2022-12-17
0
223
题解 | #计算字符串的编辑距离#
while True: try: # 此题实际上就是构造一个bp表,并且按照bp表的规则来演绎,最后取得表格有下家的元素的值 s1 = input() s2 = input() l1 = len(s1)+1 l2 = l...
2022-12-17
0
266
题解 | #截取字符串#
while True: try: c=input() k = eval(input()) # 注意整数要使用 int() / eval() 转换 print(c[:k]) except: b...
2022-12-16
0
191
题解 | #字符串加密#
while True: try: key = input() # 输入的单词 sentence = input() # 输入的需要翻译的句子 Box = [ chr(ord('a')+i) for i in range(26)] #字母表 ...
2022-12-16
0
241
题解 | #字符串合并处理#
while True: try: a = input() # 输入的字符串 # step 1 out1 = a.replace(' ','') #第一步 将空格转换为空则完成步骤一 # step 2 # 第二步 按照除以2...
2022-12-15
0
279
题解 | #字符串加解密#
while True: try: add = input() # add为需要加密的字符串 minus = input() # minus为需要解密的字符串 def lu(word): # 建一个函数其可自动转换大小写 ...
2022-12-15
0
242
首页
上一页
1
2
3
下一页
末页