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)#爱奇艺##笔试题目#