William comprehends that with all his activities he draws in increasingly more consideration from the trade's security group, so the number of his activities should not surpass 5000 and after each activity no factor can have a flat out esteem more noteworthy than 1018. William can perform activities of two kinds for two picked factors

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter19: Probabilistic Dynamic Programming
Section19.4: Further Examples Of Probabilistic Dynamic Programming Formulations
Problem 7P
icon
Related questions
Question

Correct answer will be upvoted else downvoted.

 

 

William comprehends that with all his activities he draws in increasingly more consideration from the trade's security group, so the number of his activities should not surpass 5000 and after each activity no factor can have a flat out esteem more noteworthy than 1018. William can perform activities of two kinds for two picked factors with files I and j, where i<j: 

 

Perform task ai=ai+aj 

 

Perform task aj=aj−ai 

 

William needs you to foster a system that will get every one of the interior factors to the ideal qualities. 

 

Input 

 

Each test contains numerous experiments. The main line contains the number of experiments t (1≤t≤20). Portrayal of the experiments follows. 

 

The main line of each experiment contains a solitary even integer n (2≤n≤103), which is the number of interior factors. 

 

The second line of each experiment contains n integers a1,a2,… ,an (1≤ai≤109), which are beginning upsides of inside factors. 

 

Output 

 

For each experiment print the appropriate response in the accompanying configuration: 

 

The main line of output should contain the complete number of activities k, which the system will perform. Note that you don't need to limit k. The imbalance k≤5000 should be fulfilled. 

 

Every one of the following k lines should contain activities arranged as "type I j", where "type" is equivalent to "1" if the procedure needs to play out a task of the main sort and "2" if the technique needs to play out a task of the subsequent kind. Note that i<j should hold.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole