A Riddle V2
All submissions for this problem are available.
There were four friends who used to live together in 19th century in South California. Each of them knew to solve only one kind of mathematical operator. One day, walking by a temple, they found a metal piece with N numbers engraved on it. When they showed it to the priest, he suggested that it might be an indication of the coordinates of a treasure. He also suggested that it can be cracked by performing the basic mathematical operators (/, *, +, -) in such a fashion that the operators be inserted between the numbers in the order given above and after the operators are inserted in one iteration, in the next iteration the start of the next insertion starts from the next operator from which it was inserted in previous iteration. For eg. after +, -, *, / have been inserted, in next iteration insertion starts from -, *, /, + and so goes on till one operator has been inserted between every numbers.
Help these friends to find the treasure.
- First line contains T the number of test cases.
- First line of each test case contains N.
- Next line of each test case contains A[i] the numbers they found on the metal pieces.
- For each test case solve the problem expression sequentially(in the order of the operator as they are seen from left to right) and print the required answer.
Constraints and Subtasks
Subtask 1: 10 points
Subtask 2: 90 points
Input: 1 6 4 2 6 7 2 8 Output: 136
- Given integer are 4 2 6 7 2 8 after solving it becomes 4/2*6+7-2*8= 136.
|Tags||adi28galaxyak, cakewalk, cdva16|
|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, SCALA, 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, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions