All submissions for this problem are available.
The students of IIST are developing their own satellite. So the OBC (OnBoard Computer) team being the most competent of all has been able to design a new 8-bit microprocessor which they plan to name EGSYS-1. Although being very proficient at their work, they are after all students. Thus there are many errors (failures) which occur in the microprocessor based upon various distinct factors. The testing team simulated the failures and found to their surprise that each of the failures occur at definite intervals which don't share any common factor other than 1. They have found the time at which each of the failures occurred last. They also say that when all the failures occur simultaneously the EGSYS-1 will burn off. They want you to predict that time.
The first line contains the number of test cases, t.
Each of the following t test case has the following format:
1. The first line contains an integer n indicating the number of distinct failures that occur in EGSYS-1.
2. The second line contains n integers (v1 v2 v3 … vn) indicating the intervals (in ns) at which each of the failures occur.
3. The third line contains n (A1 A2 A3 … An) integers separated by spaces indicating the last time in nano secs that each error occurred.
For each test case, the time (in ns) at which the processor fails.
Sample Input: 1 3 3 4 5 5 7 11 Sample Output: 368
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, PYTH 3.6, PYPY, GO, NODEJS, rust, swift, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.