首页 > 8-23爱奇艺测试开发算法题AC
头像
azedplayer
编辑于 2020-08-23 16:58
+ 关注

8-23爱奇艺测试开发算法题AC

1.

n = int(input())
def help(n):
    if n<5:
        return 0
    cnt = 0
    for i in range(5,n+1,5):
        cnt += 1
        while (i//5%5 == 0 and i %5 == 0):
            # print(i)
            cnt += 1
            i = i//5 
    return cnt
res = help(n)
print(res)

2.

path_list = [i for i in input()]
start = [0,0]
jw = [start]
def help(s,jw):
    if s == 'N':
        temp = [jw[-1][0],jw[-1][1]+1]
        if temp in jw:
            return 1
        jw.append(temp)
    elif s == 'S':
        temp = [jw[-1][0],jw[-1][1]-1]
        if temp in jw:
            return 1
        jw.append(temp)
    elif s == 'E':
        temp = [jw[-1][0]+1,jw[-1][1]]
        if temp in jw:
            return 1
        jw.append(temp)
    elif s == 'W':
        temp = [jw[-1][0]-1,jw[-1][1]]
        if temp in jw:
            return 1
        jw.append(temp)
    return 0

res = 0
for path in path_list:
 #   print(jw)
    res = help(path,jw)
    if res > 0:
        break
if res > 0:
    print(True)
else:
    print(False)

3.

ss = [i for i in  input()]
res = []
for s in ss:
    if res == []:
        res.append(s)
    else:
        if res[-1] == '(' and s ==')':
            res.pop(-1)
        elif res[-1] == '[' and s ==']':
            res.pop(-1)
        elif res[-1] == '{' and s =='}':
            res.pop(-1)
        else:
            res.append(s)
    # print(res)
if not res:
    print(True)
else:
    print(False)

全部评论

(6) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐