Py50分求助

P1909 [NOIP2016 普及组] 买铅笔

2,3行不知为何连在一起了。。
by Pol_Pot @ 2022-05-05 12:32:22


本蒟蒻不会呀
by Rty123 @ 2022-05-05 12:38:13


```python from math import ceil n = int(input()) l1, l2, l3 = list(map(int, input().split(' '))), list(map(int, input().split(' '))), list(map(int, input().split(' '))) num1, pri1 = l1[0], l1[1] num2, pri2 = l2[0], l2[1] num3, pri3 = l3[0], l3[1] h1, h2, h3 = ceil (n / num1), ceil (n / num2), ceil (n / num3) s1, s2, s3 = h1 * pri1, h2 * pri2, h3 * pri3 print(min(s1, s2, s3)) ``` @[xieyeheng](/user/635555) 向上取整的问题。 向上取整是 $\lceil0.9\rceil=1,\lceil1\rceil=1$ 而你的做法是 $\lfloor0.9\rfloor+1=0+1,\lfloor1\rfloor+1=2$ 这意味着我明明可以恰好买一包铅笔,非要多买一包。
by Terrible @ 2022-05-05 14:01:09


@[Terrible](/user/195942) 感谢dalao
by Pol_Pot @ 2022-05-05 15:40:28


|