A君:一年365天,工作一天进步1%,不休息一直工作;
B君:一年365天,工作一天进步x%,一周休息两天,休息天下降1%;
问:x至少为多少时,一年后B进步的速度超过A?
Adayupfactors=0.01
Bdaydownfactors=0.01
Adayup=pow(1+Adayupfactors,365)
print("The Adayup is : {:.2f}".format(Adayup))
def Dayup(Bdayupfactors):
Bdayup=1
for i in range(365):
if i%7 in [6,0]:
Bdayup=Bdayup(1-0.01)
else:
Bdayup=Bdayup(1+Bdayupfactors)
return Bdayup
Bdayupfactors=0.01
while Dayup(Bdayupfactors) < eval(str(Adayup)):
Bdayupfactors+=0.0001
print("Bdayupfactors:{:.4f}".format(Bdayupfactors))
代码为本人亲自敲写,都可以运行,转载的朋友请注明出处https://www.jianshu.com/writer#/notebooks/35294278/notes/43501316,谢谢!