Magnet Array Problem
Submissions: 4460   Accuracy:


  Difficulty: Medium   Marks: 4

Given n Magnets which are placed linearly, with each magnet to be considered as of point object. Each magnet suffers force from its left sided magnets such that they repel it to the right and vice versa. All forces are repulsive. The force being equal to the distance (1/d , d being the distance). Now given the positions of the magnets, the task to find all the points along the linear line where net force is ZERO. 
Note: Distance have to be calculated with precision of 0.0000000000001.

The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. The second line of each test case contains an integer N. Then in the next line are N space separated values of the array M[], denoting the positions of the magnet.

For each test case in a new line print the space separated points having net force zero till precised two decimal places.

1 <= T <= 100
1 <= N <= 100
1 <= M[] <= 1000


1 2
0 10 20 30
3.82 15.00 26.18

** For More Input/Output Examples Use 'Expected Output' option **

Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.