Algorithm


 problem Link :  https://www.codechef.com/problems/JERRYCHASE 

Problem

In a classic chase, Tom is running after Jerry as Jerry has eaten Tom's favourite food.

Jerry is running at a speed of  metres per second while Tom is chasing him at a speed of  metres per second. Determine whether Tom will be able to catch Jerry.

Note that initially Jerry is not at the same position as Tom.

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of two space-separated integers  and  — the speeds of Jerry and Tom respectively.

Output Format

For each test case, output on a new line, YES, if Tom will be able to catch Jerry. Otherwise, output NO.

You can print each character in uppercase or lowercase. For example NOnoNo, and nO are all considered the same.

Constraints

  • 1≤�≤100
  • 1≤�,�≤10

Sample 1:

Input
 
Output
 
4
2 3
4 1
1 1
3 5
YES
NO
NO
YES

Explanation:

Test case 1: Jerry is running at the speed of 2 metres per second while Tom is chasing him at the speed of 3 metres per second. Since Jerry's speed is less than Tom's, Tom will eventually catch Jerry.

Test case 2: Jerry is running at the speed of 4 metres per second while Tom is chasing him at the speed of 1 metres per second. Since Jerry's speed is higher than Tom's, Tom will never be able to catch Jerry.

Test case 3: Jerry is running at the speed of 1 metre per second while Tom is chasing him at the speed of 1 metre per second. Since Jerry's speed is same as that of Tom's and both of them are not at the same position, Tom will never be able to catch Jerry.

Test case 4: Jerry is running at the speed of 3 metres per second while Tom is chasing him at the speed of 5 metres per second. Since Jerry's speed is less than Tom's, Tom will eventually catch Jerry.

Code Examples

#1 Code Example with C Programming

Code - C Programming

 #include<stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        if(y>x) printf("Yes\n");
        else printf("No\n");
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4
1000 100
1000 1000
80 1
400 30

Output

x
+
cmd
19000
100000
890
6700
Advertisements

Demonstration


CodeChef solution JERRYCHASE  - Tom and Jerry Chase Codechef solution in C,C++

Previous
CodeChef solution PRIZEPOOL - Total Prize Money Codechef solution in C,C++
Next
CodeChef solution CHESSTIME - Chess Time Codechef solution in C,C++