The Jumping Kangaroo || Codechef Solution in C

  • Solution code:

 #include<stdio.h>


int main() {

// your code goes here#include <stdio.h>


    int x1; 

    int v1; 

    int x2; 

    int v2; 

    int flag=0;

    scanf("%d %d %d %d",&x1,&v1,&x2,&v2);

    if (v1<=v2)

    {

    if (x1==x2 && v1==v2)

    printf("YES");

    else

    printf("NO");

}

else

{

while(x1<x2)

{

x1+=v1;

x2+=v2;

if (x1==x2)

{flag=1;break;}

}

if (flag==1)

    printf("YES");

    else

    printf("NO");

    return 0;

}

return 0;

}

The Jumping Kangaroo || Codechef Solution in C The Jumping Kangaroo || Codechef Solution in C Reviewed by CodexRitik on November 06, 2020 Rating: 5

No comments:

Powered by Blogger.