京东9.17笔试提取年份+爬井

#1.提取年份
if __name__=='__main__':
    #A = "01003abc2020bu2019"
    A = input().strip()
    mat = ['0','1','2','3','4','5','6','7','8','9']
    temp = 0
    tmp = []
    ans = []
    for i in range(len(A)):
        if A[i] in mat:
            temp += 1
            tmp.append(A[i])
            if temp ==4:
                ans.append(tmp)
                print(ans) 
        else:
            temp = 0
            tmp = []
    tmp = []
    n = len(ans)
    res = [0] * n
    print(ans)
    for i in range(n):
        
        tmp = ''.join(ans[i])
        if int(tmp)<=3999 and int(tmp)>=1000 and len(tmp) == 4:
            res[i] = tmp
            print(res[i],end = ' ')
        else:
            continue
    



#2. 爬井
n,m = map(int,input().strip().split())
m = 100*m
count = 0
num = 0
day = 0
if n>m:
    print(0)
while count <= m:
    count += n
    day += 1

    if count >m:
        break
    else:
        num += 1
        for i in range(1,num+1):
            count -= n/(2**i)
print(day)


#京东##笔试题目#
全部评论
爬井那样例没看懂,楼主可以解释一下吗
点赞 回复
分享
发布于 2020-09-18 09:50
这题说是年份就离谱那我文字中一段电话号码,它取四位也算年份?
点赞 回复
分享
发布于 2020-09-18 11:01
联想
校招火热招聘中
官网直投

相关推荐

1 1 评论
分享
牛客网
牛客企业服务