Showing posts with label Kangaroo Hacker Rank Solution in C. Show all posts
Showing posts with label Kangaroo Hacker Rank Solution in C. Show all posts

Friday, 24 November 2017

Kangaroo Hacker Rank Solution in C

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

char* kangaroo(int x1, int v1, int x2, int v2) {
    // Complete this function
  
if(v1>v2)
{
    if((x2-x1)%(v1-v2) == 0)
        return("YES");
    else
        return("NO");
}
else
    return("NO");
}
int main() {
    int x1;
    int v1;
    int x2;
    int v2;
    scanf("%i %i %i %i", &x1, &v1, &x2, &v2);
    int result_size;
    char* result = kangaroo(x1, v1, x2, v2);
    printf("%s\n", result);
    return 0;
}