Knowee
Questions
Features
Study Tools

In a classic chase, Tom is running after Jerry as Jerry has eaten Tom's favourite food.Jerry is running at a speed of 𝑋X metres per second while Tom is chasing him at a speed of 𝑌Y 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 FormatThe first line of input will contain a single integer 𝑇T, denoting the number of test cases.Each test case consists of two space-separated integers 𝑋X and 𝑌Y — the speeds of Jerry and Tom respectively.Output FormatFor 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 NO, no, No, and nO are all considered the same.Constraints1≤𝑇≤1001≤T≤1001≤𝑋,𝑌≤101≤X,Y≤10Sample 1:InputOutput42 34 11 13 5YESNONOYESExplanation:Test case 11: Jerry is running at the speed of 22 metres per second while Tom is chasing him at the speed of 33 metres per second. Since Jerry's speed is less than Tom's, Tom will eventually catch Jerry.Test case 22: Jerry is running at the speed of 44 metres per second while Tom is chasing him at the speed of 11 metres per second. Since Jerry's speed is higher than Tom's, Tom will never be able to catch Jerry.Test case 33: Jerry is running at the speed of 11 metre per second while Tom is chasing him at the speed of 11 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 44: Jerry is running at the speed of 33 metres per second while Tom is chasing him at the speed of 55 metres per second. Since Jerry's speed is less than Tom's, Tom will eventually catch Jerry.

Question

In a classic chase, Tom is running after Jerry as Jerry has eaten Tom's favourite food.Jerry is running at a speed of 𝑋X metres per second while Tom is chasing him at a speed of 𝑌Y 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 FormatThe first line of input will contain a single integer 𝑇T, denoting the number of test cases.Each test case consists of two space-separated integers 𝑋X and 𝑌Y — the speeds of Jerry and Tom respectively.Output FormatFor 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 NO, no, No, and nO are all considered the same.Constraints1≤𝑇≤1001≤T≤1001≤𝑋,𝑌≤101≤X,Y≤10Sample 1:InputOutput42 34 11 13 5YESNONOYESExplanation:Test case 11: Jerry is running at the speed of 22 metres per second while Tom is chasing him at the speed of 33 metres per second. Since Jerry's speed is less than Tom's, Tom will eventually catch Jerry.Test case 22: Jerry is running at the speed of 44 metres per second while Tom is chasing him at the speed of 11 metres per second. Since Jerry's speed is higher than Tom's, Tom will never be able to catch Jerry.Test case 33: Jerry is running at the speed of 11 metre per second while Tom is chasing him at the speed of 11 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 44: Jerry is running at the speed of 33 metres per second while Tom is chasing him at the speed of 55 metres per second. Since Jerry's speed is less than Tom's, Tom will eventually catch Jerry.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

This problem is about determining if Tom can catch Jerry based on their respective speeds.

Here are the steps to solve this problem:

  1. First

Similar Questions

Chef has recently moved into an apartment. It takes 3030 minutes for Chef to reach office from the apartment.Chef left for the office 𝑋X minutes before Chef was supposed to reach. Determine whether or not Chef will be able to reach on time.Input FormatThe first line of input will contain a single integer 𝑇T, denoting the number of test cases.Each test case consists of a single integer 𝑋X.Output FormatFor each test case, output YES if Chef will reach on time, NO otherwise.The output is case-insensitive. Thus, the strings YES, yes, yeS, and Yes are all considered the same.Constraints1≤𝑇≤601≤T≤601≤𝑋≤601≤X≤60Sample 1:InputOutput6306014293142YESYESNONOYESYESExplanation:Test case 1: Chef leaves 3030 minutes before he is supposed to reach, so he will reach the office exactly on time since it takes 3030 minutes to commute.Test case 2: Chef will reach 3030 minutes early.Test case 3: Chef will reach 16 minutes late.

Alice is going for a drive. During her drive, she reached a maximum speed of 𝑆S km/hr.As per the rules of the government, the speed of the vehicle must not exceed 4040 km/hr, otherwise the person will be fined.You need to tell whether Alice will be fined or not.Input FormatThe only line of input will contain a single integer 𝑆S - denoting the maximum speed Alice reached while driving.Output FormatPrint YES if Alice will be fined , otherwise print NO.You may print each character of the string in uppercase or lowercase (for example, the strings YES, yEs, yes, and yeS will all be treated as identical).Constraints1≤𝑆≤501≤S≤50Sample 1:InputOutput40NOExplanation:Since Alice's speed does not exceed 4040, she will not be fined.Sample 2:InputOutput41YESExplanation:Since Alice's speed exceeds 4040, she will be fined.

There is a cricket match going on between two teams 𝐴A and 𝐵B.Team 𝐵B is batting second and got a target of 𝑋X runs. Currently, team 𝐵B has scored 𝑌Y runs. Determine how many more runs Team 𝐵B should score to win the match.Note: The target score in cricket matches is one more than the number of runs scored by the team that batted first.Input FormatThe first line of input will contain a single integer 𝑇T, denoting the number of test cases.Each test case consists of two space-separated integers 𝑋X and 𝑌Y, the target for team 𝐵B and the current score of team 𝐵B respectively.Output FormatFor each test case, output how many more runs team 𝐵B should score to win the match.Constraints1≤𝑇≤101≤T≤1050≤𝑌<𝑋≤20050≤Y<X≤200Sample 1:InputOutput4200 50100 99130 9753 511501332Explanation:Test case 11: The target is 200200 runs and team 𝐵B has already made 5050 runs. Thus, the team needs to make 200−50=150200−50=150 runs more, to win the match.Test case 22: The target is 100100 runs and team 𝐵B has already made 9999 runs. Thus, the team needs to make 100−99=1100−99=1 runs more, to win the match.Test case 33: The target is 130130 runs and team 𝐵B has already made 9797 runs. Thus, the team needs to make 130−97=33130−97=33 runs more, to win the match.Test case 44: The target is 5353 runs and team 𝐵B has already made 5151 runs. Thus, the team needs to make 53−51=253−51=2 runs more, to win the match.

Chef and his girlfriend went on a date. Chef took 𝑋X dollars with him, and was quite sure that this would be enough to pay the bill. At the end, the waiter brought a bill of 𝑌Y dollars. Print "YES" if Chef has enough money to pay the bill, or "NO" if he has to borrow from his girlfriend and leave a bad impression on her.Input FormatThe first line of input will contain a single integer 𝑇T, denoting the number of test cases.Each test case consists of a single line of input, containing two space-separated integers 𝑋X and 𝑌Y.Output FormatFor each test case, output on a new line "YES" if Chef has enough money to pay the bill and "NO" otherwise.You may print each character of the string in either uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).Constraints1≤𝑇≤1001≤T≤1001≤𝑋,𝑌≤1001≤X,Y≤100Sample 1:InputOutput41 11 22 150 100YESNOYESNOExplanation:Test case 11: Since the money Chef has is equal to the bill, he will be able to pay the bill.Test case 22: Since the money Chef has is less than the bill, he will have to borrow from his girlfriend and leave a bad impression on her.Test case 33: Since the money Chef has is greater than the bill, he will be able to pay the bill.Test case 44: Since the money Chef has is less than the bill, he will have to borrow from his girlfriend and leave a bad impression on her.

Chef is eagerly waiting for a piece of information. His secret agent told him that this information would be revealed to him after 𝐾K weeks.𝑋X days have already passed and Chef is getting restless now. Find the number of remaining days Chef has to wait for, to get the information.It is guaranteed that the information has not been revealed to the Chef yet.Input FormatThe first line of input will contain an integer 𝑇T — the number of test cases. The description of 𝑇T test cases follows.The first and only line of each test case contains two space-separated integers 𝐾K and 𝑋X, as described in the problem statement.Output FormatFor each test case, output the number of remaining days that Chef will have to wait for.Constraints1≤𝑇≤5001≤T≤5001≤𝐾≤101≤K≤101≤𝑋<7⋅𝐾1≤X<7⋅KSample 1:InputOutput41 51 61 11 22165Explanation:Test case 11: The information will be revealed to the Chef after 11 week, which is equivalent to 77 days. Chef has already waited for 55 days, so he needs to wait for 22 more days in order to get the information.Test case 22: The information will be revealed to the Chef after 11 week, which is equivalent to 77 days. Chef has already waited for 66 days, so he needs to wait for 11 more day in order to get the information.Test case 33: The information will be revealed to the Chef after 11 week, which is equivalent to 77 days. Chef has already waited for 11 day, so he needs to wait for 66 more days in order to get the information.Test case 44: The information will be revealed to the Chef after 11 week, which is equivalent to 77 days. Chef has already waited for 22 days, so he needs to wait for 55 more days in order to get the information.

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.