一道题目.
题目如下:有一500米环形跑道,甲、乙在同一点同向同时起跑,已知甲的速度为60米/分钟,乙的速度为50米/分钟。
且甲、乙跑的过程中每跑200米都要停下休息1分钟。
问:若甲追上乙一圈需要多少时间?
本人比较笨,不擅长分析这种题目。因此首先看看网上有没有方法了,果然找到了:
(http://iask.sina.com.cn/b/3112352.html)
设t为跑的时间
所以t*60=(t+Z)*50+500
t=5Z+50
所以t=60 所以甲走了3600米,所以3600/200=18 最后一次不要停,所以17次休息
t=x-y=60 所以x=60+17=77
写了一个程序来仿真一下
dt = .0001 #time step
s1=0 #how long
s2=0
t=0 #current time
t1=0 #sleep time
t2=0
next1=200 #next to sleep
next2=200
nextt=1
while s1 - s2<500:
t += dt
if t1>0: #person A sleeping
t1-=dt
else: #not sleep
t1=0
s1 += dt*60
if t2>0: #person B sleeping
t2-=dt
else: #not sleep
t2=0
s2 += dt*50
if s1>=next1 and t1==0: #person A start to sleep
t1 = 1
next1=s1+200
if s2>=next2 and t2==0: #person B start to sleep
t2 = 1
next2=s2+200
if t>=nextt:
nextt +=1
print t,s1, s2
s1=0 #how long
s2=0
t=0 #current time
t1=0 #sleep time
t2=0
next1=200 #next to sleep
next2=200
nextt=1
while s1 - s2<500:
t += dt
if t1>0: #person A sleeping
t1-=dt
else: #not sleep
t1=0
s1 += dt*60
if t2>0: #person B sleeping
t2-=dt
else: #not sleep
t2=0
s2 += dt*50
if s1>=next1 and t1==0: #person A start to sleep
t1 = 1
next1=s1+200
if s2>=next2 and t2==0: #person B start to sleep
t2 = 1
next2=s2+200
if t>=nextt:
nextt +=1
print t,s1, s2
- 上一篇 面粉增白二十年屡受质疑 中央六部门介入安全之争
- 下一篇 Mfc rtti.