All submissions for this problem are available.
Chef is working on an electronics project. In this project N wires w1, w2,w3 ... wn connect a machine to the power supply, due to a fault in the wires, wire w1 stops supplying power momentarily after every t1 seconds, wire w2 stops supplying power momentarily after every t2 seconds, and wire w3 stops supplying power momentarily after every t3 seconds and so on.
The machine keeps working as long as there is power in at least one wire. If the machine stops working, then Chef has to turn it on manually. Chef also wants to read the books so he cannot monitor the machine all the time otherwise he will get low marks in the exam. So Chef needs your help to know that After how many seconds does the machine stop working?
Note: all wires connected to power supply at t = 0 seconds. Note: Answer should be with modulo 1000000007.
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains a single integer N
- The second line of each test case contains N space seperated integers t1,t2,t3...tn where ti denotes the time after which wire wi stops supplying power momentarily
- For each test case, output a single line containing the time in seconds after which machine stops working
- 1 ≤ T ≤ 10 2
- 1 ≤ N ≤ 10 3
- 1 ≤ ti ≤ 10 5
- Time is given in seconds
Input: 2 2 2 3 3 3 2 7 Output: 6 42
Example case 1.At time = 2 seconds w1 stop working momentarily but wire w2 is still working, at time 3 seconds w2 stop working momentarily but now w1 is working. After 4 seconds again w1 stop working momentarily but w2 is working so the machine is still working. At time 6 seconds both wires stop working momentarily so machine stops working and now Chef has to start the machine again.
|Tags||easy, gcd, ince2019, lcm, modulo, prajapat786, prajapat786|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions