Will two kangaroos ever meet after making same number of jumps?











up vote
1
down vote

favorite












There are two kangaroos on an x-axis ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location $x_1$ and moves at a rate of $v_1$ meters per jump. The second kangaroo starts at location $x_2$ and moves at a rate of $v_2$ meters per jump. Given the starting locations and movement rates for each kangaroo, can you determine if they'll ever land at the same location at the same time?



Input Format



A single line of four space-separated integers denoting the respective values of $x_1$, $v_1$, $x_2$, and $v_2$.



Constraints




  1. $0 le x_1 < x_2$

  2. $1 le v_1$

  3. $1 le v_2$


Output Format



Print YES if they can land on the same location at the same time; otherwise, print NO.



Note: The two kangaroos must land at the same location after making the same number of jumps.





Sample Input 0



0 3 4 2



Sample Output 0



YES



Explanation 0



The two kangaroos jump through the following sequence of locations:




  1. 0 3 6 9 12

  2. 4 6 8 10 12


Thus, the kangaroos meet after 4 jumps and we print YES.





Sample Input 1



0 2 5 3



Sample Output 1



NO



Explanation 1



The second kangaroo has a starting location that is ahead (further to the right) of the first kangaroo's starting location (i.e., $x_2 > x_1$). Because the second kangaroo moves at a faster rate (meaning $v_2 > v_1$) and is already ahead of the first kangaroo, the first kangaroo will never be able to catch up. Thus, we print NO.





Note: I searched for the answer and got this puzzle here but without answer :( so had to ask.










share|improve this question
























  • What is the source of this puzzle?
    – Dr Xorile
    13 hours ago















up vote
1
down vote

favorite












There are two kangaroos on an x-axis ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location $x_1$ and moves at a rate of $v_1$ meters per jump. The second kangaroo starts at location $x_2$ and moves at a rate of $v_2$ meters per jump. Given the starting locations and movement rates for each kangaroo, can you determine if they'll ever land at the same location at the same time?



Input Format



A single line of four space-separated integers denoting the respective values of $x_1$, $v_1$, $x_2$, and $v_2$.



Constraints




  1. $0 le x_1 < x_2$

  2. $1 le v_1$

  3. $1 le v_2$


Output Format



Print YES if they can land on the same location at the same time; otherwise, print NO.



Note: The two kangaroos must land at the same location after making the same number of jumps.





Sample Input 0



0 3 4 2



Sample Output 0



YES



Explanation 0



The two kangaroos jump through the following sequence of locations:




  1. 0 3 6 9 12

  2. 4 6 8 10 12


Thus, the kangaroos meet after 4 jumps and we print YES.





Sample Input 1



0 2 5 3



Sample Output 1



NO



Explanation 1



The second kangaroo has a starting location that is ahead (further to the right) of the first kangaroo's starting location (i.e., $x_2 > x_1$). Because the second kangaroo moves at a faster rate (meaning $v_2 > v_1$) and is already ahead of the first kangaroo, the first kangaroo will never be able to catch up. Thus, we print NO.





Note: I searched for the answer and got this puzzle here but without answer :( so had to ask.










share|improve this question
























  • What is the source of this puzzle?
    – Dr Xorile
    13 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











There are two kangaroos on an x-axis ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location $x_1$ and moves at a rate of $v_1$ meters per jump. The second kangaroo starts at location $x_2$ and moves at a rate of $v_2$ meters per jump. Given the starting locations and movement rates for each kangaroo, can you determine if they'll ever land at the same location at the same time?



Input Format



A single line of four space-separated integers denoting the respective values of $x_1$, $v_1$, $x_2$, and $v_2$.



Constraints




  1. $0 le x_1 < x_2$

  2. $1 le v_1$

  3. $1 le v_2$


Output Format



Print YES if they can land on the same location at the same time; otherwise, print NO.



Note: The two kangaroos must land at the same location after making the same number of jumps.





Sample Input 0



0 3 4 2



Sample Output 0



YES



Explanation 0



The two kangaroos jump through the following sequence of locations:




  1. 0 3 6 9 12

  2. 4 6 8 10 12


Thus, the kangaroos meet after 4 jumps and we print YES.





Sample Input 1



0 2 5 3



Sample Output 1



NO



Explanation 1



The second kangaroo has a starting location that is ahead (further to the right) of the first kangaroo's starting location (i.e., $x_2 > x_1$). Because the second kangaroo moves at a faster rate (meaning $v_2 > v_1$) and is already ahead of the first kangaroo, the first kangaroo will never be able to catch up. Thus, we print NO.





Note: I searched for the answer and got this puzzle here but without answer :( so had to ask.










share|improve this question















There are two kangaroos on an x-axis ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location $x_1$ and moves at a rate of $v_1$ meters per jump. The second kangaroo starts at location $x_2$ and moves at a rate of $v_2$ meters per jump. Given the starting locations and movement rates for each kangaroo, can you determine if they'll ever land at the same location at the same time?



Input Format



A single line of four space-separated integers denoting the respective values of $x_1$, $v_1$, $x_2$, and $v_2$.



Constraints




  1. $0 le x_1 < x_2$

  2. $1 le v_1$

  3. $1 le v_2$


Output Format



Print YES if they can land on the same location at the same time; otherwise, print NO.



Note: The two kangaroos must land at the same location after making the same number of jumps.





Sample Input 0



0 3 4 2



Sample Output 0



YES



Explanation 0



The two kangaroos jump through the following sequence of locations:




  1. 0 3 6 9 12

  2. 4 6 8 10 12


Thus, the kangaroos meet after 4 jumps and we print YES.





Sample Input 1



0 2 5 3



Sample Output 1



NO



Explanation 1



The second kangaroo has a starting location that is ahead (further to the right) of the first kangaroo's starting location (i.e., $x_2 > x_1$). Because the second kangaroo moves at a faster rate (meaning $v_2 > v_1$) and is already ahead of the first kangaroo, the first kangaroo will never be able to catch up. Thus, we print NO.





Note: I searched for the answer and got this puzzle here but without answer :( so had to ask.







mathematics






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 18 hours ago









Glorfindel

12.7k34879




12.7k34879










asked 19 hours ago









Govind Prajapati

1655




1655












  • What is the source of this puzzle?
    – Dr Xorile
    13 hours ago


















  • What is the source of this puzzle?
    – Dr Xorile
    13 hours ago
















What is the source of this puzzle?
– Dr Xorile
13 hours ago




What is the source of this puzzle?
– Dr Xorile
13 hours ago










1 Answer
1






active

oldest

votes

















up vote
6
down vote



accepted










They'll meet if and only if




$v_1 > v_2$ (so that kangaroo 1 catches up)




and




$v_1 - v_2 | x_2 - x_1$, here | means 'is a divisor of'.




Why?




After $n in Bbb{N}$ jumps, kangaroo 1 will be at position $x_1 + n v_1$ and kangaroo 2 at $x_2 + n v_2$. Now, if
$$x_1 + n v_1 = x_2 + n v_2$$
$$n v_1 - n v_2 = x_2 - x_1$$
$$n (v_1 - v_2) = x_2 - x_1$$
$$n = frac{x_2 - x_1}{v_1 - v_2}$$
This fraction is an integer if and only if $v_1 - v_2$ divides $x_2 - x_1$.







share|improve this answer























    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "559"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fpuzzling.stackexchange.com%2fquestions%2f76401%2fwill-two-kangaroos-ever-meet-after-making-same-number-of-jumps%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    They'll meet if and only if




    $v_1 > v_2$ (so that kangaroo 1 catches up)




    and




    $v_1 - v_2 | x_2 - x_1$, here | means 'is a divisor of'.




    Why?




    After $n in Bbb{N}$ jumps, kangaroo 1 will be at position $x_1 + n v_1$ and kangaroo 2 at $x_2 + n v_2$. Now, if
    $$x_1 + n v_1 = x_2 + n v_2$$
    $$n v_1 - n v_2 = x_2 - x_1$$
    $$n (v_1 - v_2) = x_2 - x_1$$
    $$n = frac{x_2 - x_1}{v_1 - v_2}$$
    This fraction is an integer if and only if $v_1 - v_2$ divides $x_2 - x_1$.







    share|improve this answer



























      up vote
      6
      down vote



      accepted










      They'll meet if and only if




      $v_1 > v_2$ (so that kangaroo 1 catches up)




      and




      $v_1 - v_2 | x_2 - x_1$, here | means 'is a divisor of'.




      Why?




      After $n in Bbb{N}$ jumps, kangaroo 1 will be at position $x_1 + n v_1$ and kangaroo 2 at $x_2 + n v_2$. Now, if
      $$x_1 + n v_1 = x_2 + n v_2$$
      $$n v_1 - n v_2 = x_2 - x_1$$
      $$n (v_1 - v_2) = x_2 - x_1$$
      $$n = frac{x_2 - x_1}{v_1 - v_2}$$
      This fraction is an integer if and only if $v_1 - v_2$ divides $x_2 - x_1$.







      share|improve this answer

























        up vote
        6
        down vote



        accepted







        up vote
        6
        down vote



        accepted






        They'll meet if and only if




        $v_1 > v_2$ (so that kangaroo 1 catches up)




        and




        $v_1 - v_2 | x_2 - x_1$, here | means 'is a divisor of'.




        Why?




        After $n in Bbb{N}$ jumps, kangaroo 1 will be at position $x_1 + n v_1$ and kangaroo 2 at $x_2 + n v_2$. Now, if
        $$x_1 + n v_1 = x_2 + n v_2$$
        $$n v_1 - n v_2 = x_2 - x_1$$
        $$n (v_1 - v_2) = x_2 - x_1$$
        $$n = frac{x_2 - x_1}{v_1 - v_2}$$
        This fraction is an integer if and only if $v_1 - v_2$ divides $x_2 - x_1$.







        share|improve this answer














        They'll meet if and only if




        $v_1 > v_2$ (so that kangaroo 1 catches up)




        and




        $v_1 - v_2 | x_2 - x_1$, here | means 'is a divisor of'.




        Why?




        After $n in Bbb{N}$ jumps, kangaroo 1 will be at position $x_1 + n v_1$ and kangaroo 2 at $x_2 + n v_2$. Now, if
        $$x_1 + n v_1 = x_2 + n v_2$$
        $$n v_1 - n v_2 = x_2 - x_1$$
        $$n (v_1 - v_2) = x_2 - x_1$$
        $$n = frac{x_2 - x_1}{v_1 - v_2}$$
        This fraction is an integer if and only if $v_1 - v_2$ divides $x_2 - x_1$.








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 18 hours ago

























        answered 18 hours ago









        Glorfindel

        12.7k34879




        12.7k34879






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Puzzling Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fpuzzling.stackexchange.com%2fquestions%2f76401%2fwill-two-kangaroos-ever-meet-after-making-same-number-of-jumps%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Ellipse (mathématiques)

            Quarter-circle Tiles

            Mont Emei