Fork me on GitHub

NYOJ题目97兄弟郊游问题

---------------------------

 

这种问题就是列方程,然后求解就可以了。

哥哥追上弟弟的时间:

(弟弟先跑的路程/哥哥比弟弟快出来的速度)

(哥哥追上弟弟的时间*狗的速度)

 

 

AC代码:

 1 import java.util.Scanner;
 2 
 3 public class Main {
 4 
 5     public static void main(String[] args) {
 6         
 7         Scanner sc=new Scanner(System.in);
 8         
 9         int times=sc.nextInt();
10         while(times-->0){
11             int m=sc.nextInt();
12             int x=sc.nextInt();
13             int y=sc.nextInt();
14             int z=sc.nextInt();
15             
16             double ans=(x*m)*1.0/(y-x)*z;
17             System.out.printf("%.2f\n",ans);
18         }
19         
20     }
21     
22 }

 

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=97

posted @ 2016-09-21 11:51  CC11001100  阅读(210)  评论(0编辑  收藏  举报