Advertisement
AKIB37

Untitled

Mar 26th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1.  
  2. #include<stdio.h>
  3. int main()
  4. {
  5.  
  6. int t,j;
  7.  
  8. long long int x, y, a, b,l,s1,s2,c=0 ;
  9. scanf("%d",&t);
  10. for(j=1; j<=t; j++)
  11. {
  12. scanf("%lld %lld %lld %lld",&x,&y,&a,&b);
  13. l=y-x;
  14. int i=0;
  15. while(l>c)
  16. {
  17. i++;
  18. s1=a*i;
  19. s2=b*i;
  20. c=s1+s2;
  21.  
  22. }
  23.  
  24. if(l==c)
  25. {
  26. printf("%d\n",i);
  27. }
  28. else printf("-1\n");
  29. }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement