Kangaroo

Question :-

https://www.hackerrank.com/challenges/kangaroo/problem


Solution in C language :-

#include<stdio.h>
int main(){
    int x,u,y,v,i,c=0;
    scanf("%d",&x);
    scanf("%d",&u);
    scanf("%d",&y);
    scanf("%d",&v);
    for(i=0;i<10000;i++){
        x=x+u;
        y=y+v;
        if(x==y){
            printf("YES");
            c++;
            break;
        }
    }
    if(c==0){
        printf("NO");
    }
    return 0;
}

Comments

Popular posts from this blog

Sherlock and Squares

Cut The Sticks

Home