-
Notifications
You must be signed in to change notification settings - Fork 0
/
92.py
32 lines (21 loc) · 804 Bytes
/
92.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
print("M: Number of Chocolates, N: Number of empty packets, P: Number of new chocolates")
M = int(input("Enter initial chocolate amount: "))
N = int(input("Enter number of empty packets to get a new chocolate: "))
P = int(input("Enter number of new chocolate(s) correspond to empty packets: "))
Tchoco = M
while True:
if M % N == 0:
newChoco = M // N
M = newChoco * P
empPacket = newChoco * P
Tchoco += M
else:
if empPacket < N:
print("Chocolates in Total: "+str(Tchoco))
break
else:
newChoco = M // N
leftPacket = M % N
empPacket = newChoco * P + leftPacket
M = empPacket * P
Tchoco += newChoco * P