Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using recursion by java Explaination of sample: Since 4 is divisble by 2: {0, 1, 2, 3} ** {4, 5, 6, 7} = {0, 1}
Using recursion by java
Explaination of sample:
Since 4 is divisble by 2: {0, 1, 2, 3} ** {4, 5, 6, 7} =
{0, 1} ** {2, 3} +
{4, 5} ** {6, 7} +
{0, 1} ** {6, 7} +
{2, 3} ** {4, 5} =
8+120+48+48=224
Alice and Bob each have an array of integers, namely A and B. A and B have the same size, say n. Alice and Bob have come up with a new definition called "recursive product". For simplicity they use AB to show the result of the recursive product of two equal sized arrays. A* B is computed as follows: 1) If n962-1, i.e., n is an odd number, assuming the arrays indices are 0-based; 2) If n is divisible by 2, each of the arrays is divided into 2 parts of equal size. So, A will be divided to A1 and A2 (from left to right). Similarly, B is divided to B1 and B2. Then, we have Note that each ** means computing the result of the recursive product of the smaller arrays which should be computed using recursion. At the moment, Alice and Bob are working day and night to find the value of A B. We honestly do not know how they are goind to use it. However, to end their pain, write a code that finds this value! Input Format The first line has integer 1n104. The second line has n integers ao,a1,... ,an 1 of array A. and the third line has n integers bo,bi,... , bn-1 of array B Note: since there are not that many numbers in the input, you do not have to use the FastReader class. Constraints 0 a100 0 Sbi 100 Note: Even though each element in the array is not very large, the result of A** may not fit into an integer therefore, it is safer to always use a 'long' type to do the calculation:s Output Format In one line print a long value which is A**B Sample Input 0 4 123 4 567 Sample Output 0 224Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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