2017-11-24 02:59

An ant's story

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

• 点赞
• 写回答
• 关注问题
• 收藏
• 复制链接分享
• 邀请回答

4条回答

• 回答这么多问题就耍赖把我的积分一笔勾销了 3年前
• 天之上有什么 4年前
``````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.

点赞 评论 复制链接分享
• 天之上有什么 4年前
``````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");
}
}
``````

}

点赞 评论 复制链接分享
• 天之上有什么 4年前

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.

点赞 评论 复制链接分享