题解 | #记负均正#

记负均正

http://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8

永远记住:能够解题的方法就是好方法,不要一味地追求最简单的解法,不然时间成本会非常高。

while True:
    try:
        num = int(input())
        L = str(input()).split()# 要先解题,不要一味追求更简单的方法
        res1 = [] # 存放负数
        res2 = [] # 存放正数
        total = 0
        for i in L:
            if int(i) < 0:
                res1.append(int(i))
            if int(i) > 0:
                res2.append(int(i))
        for j in res2:
            total += j
        print('{} {:.1f}'.format(len(res1), total/len(res2)))
    except:
        break
全部评论

相关推荐

07-18 14:34
门头沟学院 Java
感觉招聘要求好高,这都是招什么人才
电气电子小朋友:你都说了这是大疆,无人机顶级企业,薪资30k-50k,要求高是正常的
点赞 评论 收藏
分享
程序员小白条:这比例牛逼,750:1
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务