Problem Description
Long long ago, there is an ant crawling on an L-meter magic rubber band with speed of v cm/s.The magic rubber band will elongate m meters every second. We can assume that the magic rubber band elongates equably. Now, the ant is on the start point and crawling to another point, please tell me whether it can reach the endpoint.
Input
The first line of the input is T, which stands for the number of test cases you need to solve.
Each case include three integers: L , v , m ( 0< L< 10^9,0<= v, m< 10^ 9,).
Output
For each test case, if the ant can reach endpoint, output "YES", otherwise "NO".
Sample Input
1
99999 61 1
Sample Output
YES
http://znylyuto3271.lofter.com/post/1cc1231a_413f134
I have a question.If v<m,then the ant cannot reach endpoint,yes?If so,Why did your example output yes?Please give me an interpret.
If it's the same as I think, then I may give you a solution.
public class Test {
public static void main(String[] args) {
Case a = new Case(1, 51451, 33, 2);
a.judge();
}
}
class Case {
int T, L, v, m;
double v1;
public Case(int T, int L, int v, int m) {
this.T = T;
this.L = L;
this.v = v;
this.m = m;
this.v1 = (double) this.v / 100;
System.out.println("Sample Input\n" + T + " \n" + L + " " + v + " " + m);
}
public void judge() {
if (v1 < m) {
System.out.println("Sample Output\nNo");
} else {
System.out.println("Sample Output\nYes");
}
}
}
import java.util.Scanner;
public class Test1 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int T;
System.out.print("Please input T,ends with 'Enter' key:");
T = s.nextInt();
int[][] a = new int[T][3];
System.out.println(
"Please input data L、v and m." + "Use 'Space' key to Separate input data and ends with 'enter' key.");
for (int i = 0; i < T; i++) {
System.out.println("This is case" + (i + 1) + ":");
for (int j = 0; j < 3; j++) {
a[i][j] = s.nextInt();
}
}
System.out.println("Sample INput:\n" + T);
for (int t = 0; t < T; t++) {
double b = (double) a[t][1] / 100;
System.out.println("Case" + (t + 1) + ":");
for (int h = 0; h < 3; h++) {
System.out.print(a[t][h] + " ");
}
System.out.println();
if (b < a[t][2]) {
System.out.println("Sample" + (t + 1) + " Output:" + "\nNo");
} else {
System.out.println("Sample" + (t + 1) + " Output:" + "\nYes");
}
}
}
}
In this java code,you can input data from the Console window in real time.
Good luck to you.