赞
踩
龟的时间就是l/v2
兔的时间是多方面因素决定的,可以假设它每跑m米就休息s秒,m=乌龟超过它的距离+t
- import java.util.Scanner;
-
- public class Main{
- public static void main(String[] args){
- Scanner scanner = new Scanner(System.in);
- int v1 = scanner.nextInt();
- int v2 = scanner.nextInt();
- int t = scanner.nextInt();
- int s = scanner.nextInt();
- int l = scanner.nextInt();
- scanner.close();
-
- System.out.println(getResult(v1, v2, t, s, l));
- }
-
- private static String getResult(int vRabbit, int vTurtle, int leadDist, int timeRest, int raceLength){
- int timeTurtle = raceLength / vTurtle;
-
- int timeRabbit = 0;
- int remainLength = raceLength;
- int turtlePassDist = 0;
-
- while (true){
- int t = (int)(Math.ceil((1.f * turtlePassDist + leadDist) / (vRabbit - vTurtle)));
- int currLength = t * vRabbit;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。