Taylor666
Taylor666
全部文章
分类
未归档(4)
题解(111)
归档
标签
去牛客网
登录
/
注册
陆振波的牛客博客
更多分享见:http://blog.sina.com.cn/luzhenbo2
TA的专栏
115篇文章
0人订阅
陆振波的牛客博客专栏
115篇文章
617人学习
全部文章
(共115篇)
题解 | #求解立方根#
来自专栏
''' 解题思路: 二分法,定义函数f(x)=y,输入值为y,定义一个初始区间x1、x2,中间值为xm=(x1+x2)/2, 如(f(x1)-y)*(f(xm)-y)>0,则x1=xm,否则x2=xm 要特别注意初始值x1、x2选择,本题有1、-1的约束,因为0.001**(1/3) = 0....
2021-07-01
0
351
题解 | #字符统计#
来自专栏
''' 解题思路: 字典统计字符直方图,字典的Dict.items()方法返回元组数组,可用于字典的key和value排序 ''' while 1: try: S = input().strip() #print(S) Dict = dict...
2021-07-01
0
278
题解 | #删除字符串中出现次数最少的字符#
来自专栏
''' 解题思路: 通过in方法,按字典方法计算字符直方图,找到直方图最小值。最后遍历原输入,字符数超过最小时的输出。 ''' while 1: try: S = input().strip() S.lower() Dict = dict(...
2021-07-01
1
346
题解 | #进制转换#
来自专栏
''' 解题思路: dec = int('0xFF',base=16) ''' while 1: try: print(int(input(),base=16)) except: break ''' while 1: try: ...
2021-07-01
0
305
题解 | #表示数字#
来自专栏
''' 解题思路: 将原序列数字变为1,其它为0,通过逻辑判断,找01分界点插入*号 ''' while 1: try: s = input().strip() x = [] for i in s: if i.isdig...
2021-07-01
0
295
题解 | #名字的漂亮度#
来自专栏
''' 解题思路: 统计26个字符直方图,由大小到排列,依次乘26、25、24……相加即可 ''' def f(s): t = [0]*26 for i in s: j = ord(i)-97 if j>=0 and j<=25: ...
2021-07-01
0
366
题解 | #字符串排序#
来自专栏
''' 解题思路: 记录字符+位置,字符先排序,再放回位置 ''' while 1: try: pass s = input() #print('s=',s) i_alpha = [] s_alpha = [...
2021-07-01
0
338
题解 | #DNA序列#
来自专栏
''' 解题思路: 将GC用数字1替换,其它用0替换,滑窗求和求极值,记录最大长度+开始位置 ''' s = input() n = int(input()) s2 = s.replace('G','1') s2 = s2.replace('C','1') s2 = s2.replace('A','...
2021-07-01
0
402
题解 | #查找两个字符串a,b中的最长公共子串#
来自专栏
''' 解题思路: 方法一:(穷举法)以长度小的字符串的子串是否in长串,来判断,如果in,即返回 方法二:动态规划 ''' while 1: try: A = input() B = input() if len(A)>len(B):...
2021-07-01
0
499
题解 | #合并表记录#
来自专栏
''' 解题思路: 字典可用in操作,判断键值是否存在,此题如不存在录入,如存在累加。 字典的排序返回的是key值。 字典value排序怎么搞??????????????? ''' n = int(input()) #print('n=',n) key_value = dict() # 空字...
2021-07-01
0
356
首页
上一页
1
2
3
4
5
6
7
8
9
10
下一页
末页