用的python,不造为什么第14个监测点没能通过,请教各位

P1534 不高兴的津津(升级版)

```python import math class NumPen: def __init__(self): self.pennum = None self.penprice=None ans=999999 num = int(input()) NumPens = [None]*3 for i in range(1,4): np=NumPen() np.pennum,np.penprice = map(int,input().split()) NumPens.append(np.pennum) NumPens.append(np.penprice) NumPens[i] = np x=0 y=0 for i in range(1,4): x =math.ceil(num/NumPens[i].pennum) y = x*NumPens[i].penprice if y<ans: ans=y print(ans) ```
by 羽濡 @ 2018-05-07 00:40:02


为什么你的代码这么长? ``` ans=x=0 for i in range(int(input())): s=input().split() x+=int(s[0])+int(s[1])-8 ans+=x print(ans) ``` python的精髓就在于短小精悍~
by PY_Fighter @ 2018-09-06 09:36:43


还有不是只有5个点吗?
by PY_Fighter @ 2018-09-06 09:37:22


``` n = int(input()) l = [] yest_day_unhappy = 0 today_unhappy = 0 ans = [] for i in range(n): l.append(list(map(int,input().split()))) for i in range(n): today_unhappy = yest_day_unhappy + l[i][0]+l[i][1] - 8 ans.append(today_unhappy) yest_day_unhappy = today_unhappy today_unhappy = 0 print(sum(ans))
by chidor @ 2022-07-30 21:28:44


|