HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Dynamic programming & Greedy > problem:


50485 - Center of gravity of a plate

Guest
• Review clarifications (1)

Section problems

• 50672 - Math and Soldiers
• 50671 - Phalanx
• 50842 - Minimum Sum Triangle - DP
• 50676 - Cinema Millennium
• 50678 - The Jumping Rabbit
• 51149 - One Piece Arena
• 50485 - Center of gravity of a p...
• 50674 - Collecting Eggs
• 50677 - The Cottage
• 50675 - Kruja Boys
• 50679 - Jetpack Hurdle Jumping
• 50673 - DNA Testing
• 50997 - Dynamic Knights
• 50936 - Saving the Soldiers
• 50979 - Minimum access cost for BST

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

Center of gravity of a plate

National Science academy, for an experiment, needs to calculate the center of gravity (weight center) of an irregular plate. The plate has tabular format and it has different weights on its every cell (e.g. the left figure).

In physics, center of gravity is the point where relative distributed mass sums to zero.

Center of gravity of a rectangular-irregular shape is the point where the difference between sum of weighted relative positions on the left-right and up-down sides are close to zero.

Assuming that

  • the objects have fixed width (1cm each)
  • all objects are pin-point objects and have their center of gravity in their centers (5mm, 5mm)
For example, if we have the following 5-by-1 rectangular object (right image) with the weights: 2, 3, 1, 1, 3.
Then, the weight center of the series is 2.5cms from the left and 0.5cms from the top. Because
  2*2 + 3*1 + 1*0 = 1*1 + 3*2
and thus sum of weighted relative positions on the left and right sides are equal to zero.

Question: Write a program that is going to read the weights on a rectangular object and decide the center of gravity.

Input specification
There are two numbers (m and n) at the beginning representing height and width of the rectangular object. Each of the following m lines have n-integers numbers where 1 ≤ (m and n) ≤ 1000, and the numbers are between 0 and 100.

Output specification
Show x and y positions of weight center with a 0.01cm precision.

 Sample Input I     Sample Input II   
3 3
1 2 2
1 2 2
4 8 8
4 4
15 22 16 19
14 7 15 10
7 12 4 17
19 2 14 7
 Sample Output I     Sample Output II   
1.7 2 2 1.76


Explanation: You can use the following formula to calculate the centers:

Для отправки решений необходимо выполнить вход.

www.contester.ru