python RE 求助

P1150 Peter 的烟

flypig_three @ 2023-08-31 13:57:03


n = int(input())
k = int(input())
cnt = 0
ret = 0
while n > 0 :
    ret = ret + n
    cnt = cnt + n
    n = cnt / k
    cnt = cnt % k
print (ret)

by Terrible @ 2023-08-31 14:08:11

@Laughing_shx

读入一行两个数用

n,k=map(int,input().split())

另外建议使用 cnt//k 是向下取整除法。


by flypig_three @ 2023-08-31 14:12:47

@Terrible 过了,感谢


|