首页 > 美团笔试8-15
头像
给我一个offer叭!!!
编辑于 2020-08-16 15:59
+ 关注

美团笔试8-15

1.求逆序数对的个数 
def inverse_num(a):
    if a==0:
        return 0
    else:
        num_list=list(str(a))
        while num_list[-1]=='0':
            num_list.pop()
        temp=''.join(num_list[::-1])
        return temp
if __name__=='__main__':
    n=int(input())
    count=0
    list1=[]
    for i in range(1,n+1):
        if i*4==int(inverse_num(i)):
            count+=1
            list1.append(i)
            list1.append(int(inverse_num(i)))
    print(count)
    for i in range(0,len(list1),2):
        print(list1[i],list1[i+1])
没有全A,不知到错在哪里

有没有大佬可以分享今天剩下题的思路呀

全部评论

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

推荐话题

相关热帖

近期热帖

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

近期精华帖

热门推荐