|
@@ -0,0 +1,47 @@
|
|
|
|
+class calcd(object):
|
|
|
|
+ def __init__(self,yuan):
|
|
|
|
+
|
|
|
|
+ self.bottelunit=3
|
|
|
|
+ self.capunit=4
|
|
|
|
+ self.unit=5
|
|
|
|
+
|
|
|
|
+ self.num=yuan//self.unit
|
|
|
|
+ self._gai=0
|
|
|
|
+ self._ping=0
|
|
|
|
+
|
|
|
|
+ def calcp3(self,p):
|
|
|
|
+ r=(p+self._ping)
|
|
|
|
+ self._ping=r%self.bottelunit
|
|
|
|
+ if r>=self.bottelunit:
|
|
|
|
+ self.num+=r//self.bottelunit
|
|
|
|
+ return r//self.bottelunit
|
|
|
|
+ return 0
|
|
|
|
+
|
|
|
|
+ def calcg4(self,g):
|
|
|
|
+ r=(g+self._gai)
|
|
|
|
+ self._gai=r%self.capunit
|
|
|
|
+ if r>=self.capunit:
|
|
|
|
+ self.num+=r//self.capunit
|
|
|
|
+ return r//self.capunit
|
|
|
|
+ return 0
|
|
|
|
+
|
|
|
|
+ def go(self):
|
|
|
|
+
|
|
|
|
+ x=self.num
|
|
|
|
+ p= self.calcp3(x)
|
|
|
|
+ g= self.calcg4(x)
|
|
|
|
+ x=p+g
|
|
|
|
+
|
|
|
|
+ while (x+self._gai)>=self.capunit or (x+self._ping)>=self.bottelunit:
|
|
|
|
+ print('换取%d瓶酒' %x)
|
|
|
|
+ print('剩余%d瓶盖' %self._gai)
|
|
|
|
+ print('剩余%d空瓶' %self._ping)
|
|
|
|
+ g=self.calcg4(x)
|
|
|
|
+ p=self.calcp3(x)
|
|
|
|
+ x=g+p
|
|
|
|
+
|
|
|
|
+if __name__=="__main__":
|
|
|
|
+ c=calcd(528)
|
|
|
|
+ c.go()
|
|
|
|
+ print ('--%s' %c.num)
|
|
|
|
+
|