Advertisement
ChasedByDeath

Problem given by Mahe

Oct 4th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. import static java.lang.System.*;
  2. import java.util.*;
  3. public class p01FleaCircus {
  4.   public static void main(String[] args) {
  5.     Scanner po = new Scanner(in);
  6.     out.println("Position of the first flea:");
  7.     int x1 = po.nextInt();
  8.     out.println("Move rate of the first flea:");
  9.     int v1 = po.nextInt();
  10.     out.println("Position of the second flea:");
  11.     int x2 = po.nextInt();
  12.     out.println("Move rate of the second flea:");
  13.     int v2 = po.nextInt();
  14.     if(v1==v2) {
  15.       if(x1==x2)
  16.         out.println("YES");
  17.       else
  18.         out.println("NO");
  19.     }
  20.     else {
  21.       int steps = (x2-x1)/(v1-v2);
  22.       if(steps<=0)
  23.         out.println("NO");
  24.       else {
  25.       //if((x1+steps*v1)==(x2+steps*v2))
  26.         out.println("YES");
  27.       //else
  28.         //out.println("NO");
  29.       }
  30.     }
  31.   }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement