划算与不划算的看法,求出1003
来源:8-13 划算还是不划算
有点跳的抓马
2018-10-23
def l1():
l1_gold=0.75
l1_diamond=8
l1_value=l1_gold+l1_diamond*0.05
print(‘l1 is :’,l1_value)
print(’~~~~~~~~~~~~~~~~~’)
return l1_value
l1_final_value=l1()
def l3():
l3_gold=0.39
l3_vit=10
l3_value=l3_gold+l3_vit+13*l1_final_value
print(‘l3 is :’,l3_value)
return l3_value
l3_final_value=l3()
def l4():
l4_gold=0.897
l4_vit=10
mean=(l4_gold+l4_vit+l3_final_value+16l1_final_value)0.4878+0.5122(0.897+16l1_final_value)
l4_value=(1/0.4878)*mean
print(‘l4 is :’,l4_value)
return l4_value
l4_final_value=l4()
def l5():
l5_gold=19.75
l5_vit=10
l5_value=l5_gold+l5_vit+13l4_final_value
print(‘l5 is :’,l5_value)
return l5_value
l5_final_value=l5()
if l5_final_value>750:
print(‘直接购买6级石划算’)
else:
print(‘自己升级更划算’)
老师,我用手算的方式,求得1级石头1.15,3级石25.34,3级转4级时候,我假设失败n次才成功一次,那失败率就是n/(n+1)=1-0.4878,求得n=1.05,也就是说要失败1.05次才会成功一次,那我假设一定成功时,4级石求得54.637,一定失败时,4级石19.297
所以结合失败和成功的概率,就是19.297n(1.05)+54.637=74.89
我最后的答案是1003,不知道为什么是913
2回答
-
Brave_chi
2018-12-14
""" 购买一颗1级石头花费的金币 """ def one_l1_pay(): result = l1_value + l1_value_diamond * 0.05 print("1级石头消耗金币" + str(round(result,2))) return result """ 合成一颗3级石头花费的金币 """ def one_l3_pay(): a = one_l1_pay() # 12个1级 + 金币 + 体力 result = l1_to_l3 * a + l1_to_l3_gold + (l1_to_l3_vit*1) print("三级石头消耗金币" + str(round(result,2))) return round(result,2) """ 合成一颗4级石头花费的金币 ################################## # # 成功 # 失败 # # # p # 1-p # # 消耗 # 16*l1石 # 16*l1石 # # 消耗 # 0.897金币 # 0.897金币 # # 消耗 # 10体力 # # #金币消耗# g1 # g2 # ################################## 举例说明:如果操作m次,那么成功的次数是mp次,失败m(1-p)次,总消耗s=mp*g1+m(1-p)*g2 平均每成功一次的消耗就是:s1 = s/mp = mp*g1+m(1-p)*g2/mp =====> S1 = g1 +((1-p)/p)*g2 """ def one_l4_pay(): a1 = one_l1_pay() a3 = one_l3_pay() # 成功时消耗的金币:1个3级 + 16个1级 + 金币 + 体力 g1 = a3 + l3_to_l4 * a1 + l3_to_l4_gold + (l3_to_l4_vit*1) # 失败时消耗的金币 g2 = l3_to_l4 * a1 + l3_to_l4_gold # 成功率 l3_to_l4_rate,失败率 (1-l3_to_l4_rate) 并且丢失16个一级和金币 result = g1 + ((1-l3_to_l4_rate)/l3_to_l4_rate) * g2 print("四级石头消耗金币" + str(round(result,2))) return round(result,2) """ 合成一颗6级石头花费的金币 """ def one_l6_pay(): a4 = one_l4_pay() # 12颗4级石头 + 金币 + 体力 result = l4_to_l6 * a4 + l4_to_l6_gold + l4_to_l6_vit return round(result,2) result = one_l6_pay() print("合成一个六级石头消耗金币" + str(result))
答案是六级石914.75,1级1.15,3级24.19,四级73.75
512019-01-06 -
NTeam6
2019-11-13
老师题目给的不是特别明确,对于消耗的理解不一样,结果也不一样,914、928、988、1003、1247都能算出来。主体程序都是一样的,根据不同理解改一下其中某个变量的值,以上几个结果都能算出来。
10
相似问题