View Code of Problem 104

import  java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()) {
			int n = scanner.nextInt();
			int v1 = scanner.nextInt();
			int v2 = scanner.nextInt();
			int t = scanner.nextInt();
			if(v1 < v2) {
				System.out.println("NO");
			}else {
				if((v1-v2) * t < n*1000 ){
					System.out.println("NO");
				}else {
					double time =(double)n*1000 / (v1 - v2);
					System.out.println(String.format("%.2f", time));
				}
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 104