SP8420 BTCODE_B - Finding Minimum
Description
You are given 'n' integers k $ _{1} $ , k $ _{2} $ , ...., k $ _{n} $ and an integer 'x', which satisfy the equation x $ _{1} $ $ ^{k1} $ \* x $ _{2} $ $ ^{k2} $ \* ..... \* x $ _{n} $ $ ^{kn} $ = x. You are also given values a $ _{1} $ , a $ _{2} $ , ...., a $ _{n} $ and y $ _{1} $ , y $ _{2} $ , ...., y $ _{n} $ . Your task is to find the least positive value 'v', that can be taken by the expression: a $ _{1} $ \*x $ _{1} $ $ ^{y1} $ + a $ _{2} $ \*x $ _{2} $ $ ^{y2} $ + ... + a $ _{n} $ \*x $ _{n} $ $ ^{yn} $ . Note that x $ _{1} $ , x $ _{2} $ , x $ _{3} $ , ..... x $ _{n} $ are some variables (not necessarily integers), which can only take positive values.
Input Format
The first line of input contains a single integer 't', denoting the number of test cases.
The first line of each testcase contains two space separated integers 'n' and 'x'.
Next line contains 'n' integers k $ _{1} $ , k $ _{2} $ , ..., k $ _{n} $ .
Next line contains 'n' integers a $ _{1} $ , a $ _{2} $ , ..., a $ _{n} $ .
Next line contains 'n' integers y $ _{1} $ , y $ _{2} $ , ..., y $ _{n} $ .
Output Format
For each testcase output the least positive value 'v' that can be taken by the expression. To avoid floating point errors, round it off to the nearest integer.
For example, 12.6 is rounded off to 13, and 12.4 is rounded off to 12. To avoid ambiguity, there will be no test case for which the fractional part of the answer equals 0.5.