美团 9.20 测开笔试

第一题:六位数
m,n=map(int,input().split())
count=0
for i in range(m,n+1):
    cur=str(i)
    tmp=set(cur)
    if len(tmp)==6 and int(cur[:2])+int(cur[2:4])-int(cur[4:])==0:
        count+=1
print(count)

第二题:小美的新游戏(类似机器人有障碍路径),开始位置也要置为'+'。
n,m,p,q=map(int,input().split())
path,res=[],[]
for _ in range(n):
    path=list(input())
    res.append(path)
step=input()

for i in range(n):
    for j in range(m):
        if res[i][j]=='S':
            res[i][j]='+'
            x,y=i,j
            break

count=0 
for i in step:
    if i=='W':
        if x==0 or res[x-1][y]=='#':
            continue
        if res[x-1][y]=='O':
            count+=p
            res[x-1][y]='+'
            x-=1
        elif res[x-1][y]=='X':
            count-=q
            res[x-1][y]='+'
            x-=1
        elif res[x-1][y]=='+':
            x-=1
    elif i=='S':
        if x==n-1 or res[x+1][y]=='#':
            continue
        if res[x+1][y]=='O':
            count+=p
            res[x+1][y]='+'
            x+=1
        elif res[x+1][y]=='X':
            count-=q
            res[x+1][y]='+'
            x+=1
        elif res[x+1][y]=='+':
            x+=1
    elif i=='A':
        if y==0 or res[x][y-1]=='#':
            continue
        if res[x][y-1]=='O':
            count+=p
            res[x][y-1]='+'
            y-=1
        elif res[x][y-1]=='X':
            count-=q
            res[x][y-1]='+'
            y-=1
        elif res[x][y-1]=='+':
            y-=1
    else:
        if y==m-1 or res[x][y+1]=='#':
            continue
        if res[x][y+1]=='O':
            count+=p
            res[x][y+1]='+'
            y+=1
        elif res[x][y+1]=='X':
            count-=q
            res[x][y+1]='+'
            y+=1
        elif res[x][y+1]=='+':
            y+=1
print(count)

第三题:小美找朋友(类似子序列)
n,m=map(int,input().split())
s1=input()
s2=input()
Flag=True
index,cur=-1,-1
res=[]
for c in s2:
    if s1.find(c)==-1:
        Flag=False
if Flag:
    for c in s2:
        index=s1.find(c,index+1)
        if index<cur:
            Flag=False
            break
        cur=index

        res.append(index)
if Flag:
    print('Yes')
    print(sum(res)+len(s2))
else:
    print('No')
第四题:小美的美丽树(子树的最大值最小值之差)😛
print(2)




#笔试题目#
全部评论
第三题忘了print yes no了....
点赞 回复
分享
发布于 2020-09-20 12:07
最后一题print(5)能过18%...
点赞 回复
分享
发布于 2020-09-20 12:08
百信银行
校招火热招聘中
官网直投
mark一下
点赞 回复
分享
发布于 2020-09-20 14:16
大佬 我第二题为啥过不去呢
点赞 回复
分享
发布于 2020-09-20 14:19
print(2)🤣
点赞 回复
分享
发布于 2020-09-20 18:25
美团笔试可以回过头再做之前的题目吗,还是点了下一题就回不了头了
点赞 回复
分享
发布于 2020-09-26 23:06
楼主有收到面试消息嘛?
点赞 回复
分享
发布于 2020-09-27 14:41

相关推荐

4 8 评论
分享
牛客网
牛客企业服务