CCF&Python 2017-3-1 分蛋糕

原题目

CCF&Python 2017-3-1 分蛋糕

思路

一次往后加,大于了k,就清零,计数加一。直到分完

n,k=map(int,input().split())
num_list=list(map(int,input().split()))
result=0
temp=0
for i in range(n):
    temp=temp+num_list[i]
    if temp>=k:
        result+=1
        temp=0
if temp>0:result+=1
print(result)

备注

小明啊,蛋糕可以切啊,你买蛋糕没送你塑料刀吗??

相关文章:

  • 2021-04-20
  • 2021-12-12
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2021-09-11
  • 2021-04-27
猜你喜欢
  • 2021-09-03
  • 2021-09-10
  • 2021-09-09
  • 2021-04-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案