fork download
  1. #include <math.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <assert.h>
  6. #include <limits.h>
  7. #include <stdbool.h>
  8.  
  9. int main(){
  10. int x1,x2,v1,v2,s1,s2,t,x,y,f=0,i;
  11. scanf("%d %d %d %d",&x1,&v1,&x2,&v2);
  12. for(t=1;t<=100000;t++)
  13. {
  14. s1=x1+(v1*(t-i));
  15. s2=x2+(v2*(t-i));
  16. if(s1==s2)
  17. {
  18. printf("YES");
  19. f=f+1;
  20. break;
  21. }
  22. else
  23. {
  24. x1=s1;
  25. x2=s2;
  26. i=t;
  27. continue;
  28. }
  29. }
  30. if(f==0)
  31. printf("NO");
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 2172KB
stdin
0 7 6 1
stdout
NO