fork download
  1. import java.util.*;
  2. public class Main {
  3.  
  4.  
  5. public static void main(String[] args) {
  6. Scanner input=new Scanner(System.in);
  7. int xa=input.nextInt();
  8. int ya=input.nextInt();
  9. int ua=input.nextInt();
  10. int la=input.nextInt();
  11. int xb=input.nextInt();
  12. int yb=input.nextInt();
  13. int ub=input.nextInt();
  14. int lb=input.nextInt();
  15.  
  16. int pointx=xb;
  17. int pointy=ya;
  18. double t1a,t2a,t1b,t2b;
  19. if(ua==0)
  20. {
  21. t1a=0;
  22. t2a=Double.MAX_VALUE;
  23.  
  24. }
  25. else
  26. {
  27. t1a=(double)(pointx-xa)/ua;
  28. t2a=(double)(pointx-(xa+la))/ua;
  29. }
  30.  
  31. if(ub==0)
  32. {
  33. t1b=0;
  34. t2b=Double.MAX_VALUE;
  35.  
  36. }
  37. else
  38. {
  39. t1b=(double)(pointy-yb)/ub;
  40. t2b=(double)(pointy-(yb+lb))/ub;
  41. }
  42. if((t1a<0 && t2a<0) || (t1b<0 && t2b<0))
  43. {
  44. System.out.println("no");
  45. return;
  46. }
  47. if(t1a<0)
  48. {
  49. t1a=0;
  50. }
  51. if(t2a<0)
  52. {
  53. t2a=0;
  54. }
  55. if(t1b<0)
  56. {
  57. t1b=0;
  58. }
  59. if(t2b<0)
  60. {
  61. t2b=0;
  62. }
  63. double firsta,firstb,seconda,secondb;
  64. if(t1a<t2a)
  65. {
  66. firsta=t1a;
  67. seconda=t2a;
  68. }
  69. else
  70. {
  71. firsta=t2a;
  72. seconda=t1a;
  73. }
  74. if(t1b<t2b)
  75. {
  76. firstb=t1b;
  77. secondb=t2b;
  78. }
  79. else
  80. {
  81. firstb=t2b;
  82. secondb=t1b;
  83. }
  84. System.out.println(Math.min(seconda,secondb)-Math.max(firsta,firstb));
  85. if(Math.min(seconda,secondb)-Math.max(firsta,firstb)>0.000001)
  86. {
  87. System.out.println("yes");
  88. }
  89. else
  90. {
  91. System.out.println("no");
  92. }
  93.  
  94. }
  95. }
Success #stdin #stdout 0.11s 56560KB
stdin
1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 0 1000000000
stdout
0.0
no