zoukankan      html  css  js  c++  java
  • 一道题目

    题目如下:
    有一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
        

  • 相关阅读:
    k8s dashboard 配置使用kubeconfig文件登录
    Spring Cloud 专题之七:Sleuth 服务跟踪
    Spring Cloud 专题之六:bus 消息总线
    Spring Cloud专题之五:config 配置中心
    Docker Storage Driver:存储驱动
    Docker引擎升级教程
    Docker介绍及安装详解
    Autowired和Resource的区别和联系
    OLTP与OLAP
    转载-JAVA 关于JNI本地库加载
  • 原文地址:https://www.cnblogs.com/cutepig/p/1418097.html
Copyright © 2011-2022 走看看