NYOJ题目97兄弟郊游问题
2016-09-21 11:51
274 查看
---------------------------
这种问题就是列方程,然后求解就可以了。
哥哥追上弟弟的时间:
(弟弟先跑的路程/哥哥比弟弟快出来的速度)
(哥哥追上弟弟的时间*狗的速度)
AC代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int times=sc.nextInt(); while(times-->0){ int m=sc.nextInt(); int x=sc.nextInt(); int y=sc.nextInt(); int z=sc.nextInt(); double ans=(x*m)*1.0/(y-x)*z; System.out.printf("%.2f\n",ans); } } }
相关文章推荐