题解 | #记负均正#
记负均正
https://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
# !/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'tianyi' __date__ = '2024/3/25 10:15 ' __file__ = 'HW_HJ97.py' import sys # 1. 读取输入 count = 0 count_0 = 0 total = 0 less_0 = 0 for i in sys.stdin: i = [int(n) for n in i.split()] if len(i) > 1: for j in i: if j > 0: total += j elif j < 0: less_0 += 1 else: count_0 += 1 elif len(i) == 1: count = i[0] #total保留一位小数.兼容分母为0的情况 if count_0 == count: print(str(less_0)+" "+str(0.0)) else: print(str(less_0)+" "+str(round(total/(count-less_0-count_0),1)))