Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static java.lang.System.*;
- import java.util.*;
- public class p01FleaCircus {
- public static void main(String[] args) {
- Scanner po = new Scanner(in);
- out.println("Position of the first flea:");
- int x1 = po.nextInt();
- out.println("Move rate of the first flea:");
- int v1 = po.nextInt();
- out.println("Position of the second flea:");
- int x2 = po.nextInt();
- out.println("Move rate of the second flea:");
- int v2 = po.nextInt();
- if(v1==v2) {
- if(x1==x2)
- out.println("YES");
- else
- out.println("NO");
- }
- else {
- int steps = (x2-x1)/(v1-v2);
- if(steps<=0)
- out.println("NO");
- else {
- //if((x1+steps*v1)==(x2+steps*v2))
- out.println("YES");
- //else
- //out.println("NO");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement