Question
Tick, tock, tick, tock, the clock ticks while showing that its already 6 am now. Usually at around this time one would hear the sound
“Tick, tock, tick, tock”, the clock ticks while showing that it’s already 6 am now. Usually at around this time one would hear the sound of a rooster crowing in the morning, however that doesn’t happen here in Jojo’s house. Each morning instead of hearing the crow of a rooster Jojo hears the sound of a crow instead, it’s weird and nobody knows exactly why that happens.
Anyways it’s a beautiful morning so far until Jojo decided to check new text messages on his phone, he’s shocked to learn that all of a sudden his girlfriend unilaterally decides to end their relationship at that very moment! Nobody knows what it is that has possessed his (now ex) girlfriend that makes her have the heart to betray Jojo, who loves her sincerely. Now Jojo is very sad and he decided to do his hobby that is to cook his favorite food to alleviate his sadness.
The food Jojo wants to cook consists of N ingredients, the amount of the i-th ingredient needed is Ai grams and Jojo already has Bi grams of that particular ingredient. Help Jojo to find out if he already has enough of the necessary ingredients or if he needs to buy some more at the store!
Format Input
The input consists of T testcases where for each testcase the value of N , Ai and Bi might be different. The first line of the input then contains T which is the number of testcases. The first line of each testcase contains N , the number of ingredients needed. The second line of each testcase contains N numbers (Ai) which shows how many grams of the i-th ingredient needed to cook the food. The third line of each testcase contains N numbers (Bi) which shows how many grams of the i-th ingredient Jojo already has.
Format Output
The output consists of T lines where each line contains “Case #X: ” (without quotes) where X is the number of the testcase starting from 1 followed by N numbers. The i-th number shows how many grams of the i-th ingredient Jojo needs to buy to cook the food. If Jojo already has more of the i-th ingredient than necessary, show a negative sign (-) followed by how many grams of the i-th ingredient Jojo is going to have left after cooking his food. See explanation more clarity.
Constraints
• 1≤T≤100
• 1≤N≤100
• 1≤Ai,Bi ≤100000
Sample Input (standard input)
2
5 34518 13915 3
543 345
Sample Output (standard output)
Explanation for the first testcase
Case #1: 2 1 -4 0 3 Case #2: 2 0 -2
On the first testcase, 5 ingredients are needed to cook the food.
• Jojo needs 3 grams of the 1st ingredient and already has 1 gram of that ingredient,
• meaning that he needs to buy 2 grams of the 1st ingredient.
• Jojo needs 4 grams of the 2nd ingredient and already has 3 gram of that ingredient,
meaning that he needs to buy 1 gram of the 2nd ingredient.
• Jojo needs 5 grams of the 3rd ingredient and already has 9 gram of that ingredient, meaning that he is going to have 4 grams of the 3rd ingredient left after cooking his
• food.
• Since Jojo already has more of the 3rd ingredient than necessary, the program needs
to output a negative sign before the number 4. •J
• Jojo needs 1 gram of the 4th ingredient and already has 1 gram of that ingredient, meaning that he needs to buy 0 grams of the 4th ingredient.
• Jojoneeds8gramsofthe5thingredientandalreadyhas5gramsofthatingredient, meaning that he needs to buy 3 grams of the 5th ingredient
Step by Step Solution
3.38 Rating (160 Votes )
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