Question
Please format the answer so it can be typed on a basic notepad. The answer must be in R. Thank you in advance. MUST BE
Please format the answer so it can be typed on a basic notepad. The answer must be in R. Thank you in advance.
MUST BE IN R
At a shopping mall, every now and then, a naughty kid steals some chocolates from different chocolate shops and runs away. The guards in the shopping mall were unable to catch the kid as he has got a fast scooter.
Each scooter has a performance value. Also, this kind of scooter needs a skilled rider to perform well. The total performance of a rider is measured by the value of scooter performance multiplied by riders skill. A rider X can catch a rider Y only if Xs total performance is more than Ys.The shopping mall manager has bought one scooter for each guard. However, as he has bought them from a wholesale offer, their performance values need not be the same.
Each guard gets a scooter and of course, a scooter can be assigned to only one guard. Now, the manager wants to assign the scooters to the guards. Everyday the guards are on duty in different places and that's why each must be able to catch the kid and only then an assignment will be valid.
So in short, given the skill of that kid, his scooters performance value, each guards skill, and each scooters performance value, find out the number of valid assignments possible. In a valid assignment, each guard will be able to catch the kid. As the result, can be very large, find the mod 10^9 + 7 of the result.
INPUT
The first line of the input contains an integer T denoting the number of test cases. The description of each test case follows.
The first line of each test case contains two integers Kp and Ks denoting the kid's performance value and his scooter's performance value respectively.
The next line contains a single integer N denoting the number of guards.
The third line contains N integers G1, G2, G3, ... , GN denoting the performance values of the guards.
The fourth line of each test case contains N integers S1, S2, S3, ... , SN denoting the performance values of the scooters.
OUTPUT
For each test case, print "Case i: ", and then the answer (mod 10^9 + 7), where i is the testcase number, 1-indexed.
CONSTRAINTS
1 T 10
1 N, Kp, Ks, Gi, Si 106
EXAMPLE
Input:
2
2 3
3
3 1 3
7 3 4
2 3
3
3 1 3
2 7 4
Output:
Case 1: 2
Case 2: 0
MUST BE IN R At a shopping mall, every now and then, a naughty kid steals some chocolates from different chocolate shops and runs away. The guards in the shopping mall were unable to catch the kid as he has got a fast scooter. Each scooter has a performance value. Also, this kind of scooter needs a skilled rider to perform well. The total performance of a rider is measured by the value of scooter performance multiplied by rider's skill. A rider X can catch a rider Y only if X's total performance is more than Y's.The shopping mall manager has bought one scooter for cach guard. However, as he has bought them from a wholesale offer, their performance values need not be the same. Each guard gets a scooter and of course, a scooter can be assigned to only one guard. Now, the manager wants to assign the scooters to the guards. Everyday the guards are on duty in different places and that's why cach must be able to catch the kid and only then an assignment will be valid. So in short, given the skill of that kid, his scooter's performance value, cach guard's skill, and cach scooter's performance value, find out the number of valid assignments possible. In a valid assignment, cach guard will be able to catch the kid. As the result, can be very large, find the mod 109+7 of the result. INPUT .The first line of the input contains an integer T denoting the number of test cases. The description of cach test case follows. The first line of each test case contains two integers K, and K, denoting the kid's performance value and his scooter's performance value respectively . The next line contains a single integer N denoting the number of guards. .The third line contains N integers G, G, G... , Gs denoting the performance values of the guards. .The fourth line of cach test case contains N integers S, S, S..., Sv denoting the performance values of the scooters. OUTPUT For cach test case, print Casei ", and then the answer (mod 109+7), where i is the testcase number, 1-indexed. CONSTRAINTS 1sTs10 1N,K, K., G, S 10 EXAMPILE Input: 2 3 3 1 3 73 2 3 3 1 3 27 Output Case 1: 2 Case 2:0 MUST BE IN R At a shopping mall, every now and then, a naughty kid steals some chocolates from different chocolate shops and runs away. The guards in the shopping mall were unable to catch the kid as he has got a fast scooter. Each scooter has a performance value. Also, this kind of scooter needs a skilled rider to perform well. The total performance of a rider is measured by the value of scooter performance multiplied by rider's skill. A rider X can catch a rider Y only if X's total performance is more than Y's.The shopping mall manager has bought one scooter for cach guard. However, as he has bought them from a wholesale offer, their performance values need not be the same. Each guard gets a scooter and of course, a scooter can be assigned to only one guard. Now, the manager wants to assign the scooters to the guards. Everyday the guards are on duty in different places and that's why cach must be able to catch the kid and only then an assignment will be valid. So in short, given the skill of that kid, his scooter's performance value, cach guard's skill, and cach scooter's performance value, find out the number of valid assignments possible. In a valid assignment, cach guard will be able to catch the kid. As the result, can be very large, find the mod 109+7 of the result. INPUT .The first line of the input contains an integer T denoting the number of test cases. The description of cach test case follows. The first line of each test case contains two integers K, and K, denoting the kid's performance value and his scooter's performance value respectively . The next line contains a single integer N denoting the number of guards. .The third line contains N integers G, G, G... , Gs denoting the performance values of the guards. .The fourth line of cach test case contains N integers S, S, S..., Sv denoting the performance values of the scooters. OUTPUT For cach test case, print Casei ", and then the answer (mod 109+7), where i is the testcase number, 1-indexed. CONSTRAINTS 1sTs10 1N,K, K., G, S 10 EXAMPILE Input: 2 3 3 1 3 73 2 3 3 1 3 27 Output Case 1: 2 Case 2:0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started