HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


140. 50599 - Sum of Squared Error (SSE) Distance

Guest
• Review clarifications (1)

Volume problems

• 010. 50381 - Sum of the numbers
• 030. 50737 - Sum of the k-largest n...
• 060. 50389 - Reverse an Array
• 100. 50330 - Find the average of n ...
• 110. 50359 - Mode of a Series
• 120. 50331 - Number of Numbers o...
• 120. 50329 - Draw Matrix-1
• 125. 50538 - Sum of kth Diagonal
• 140. 50599 - Sum of Squared Er...
• 15-SprPrE1-80. 50741 - DNA Distance
• 151. 50557 - nth Power of m (Long...
• 155. 50334 - What is the class aver...
• 155. 50726 - Pascal Triangle - 1
• 160. 50301 - Fractions to Decimals
• 165. 50360 - National Elections
• 170. 50319 - Toll Plazas
• 180. 50755- Top N Donors - 1

Feedback

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

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

Sum of Squared Error (SSE) Distance

Shqip

Sum of squared error is used to find the closest match of one vector or array. You subtract every element of a vector (one dimensional array) from every element of another vector. Then you calculate the sum of squares to calculate the SSE distance using the following formula:


You will be given a one dimensional array containing n floating point numbers. There are m other n-element testing vectors which are to be compared with the original data. And, you are to find out the one which is closest (or same) to the original data.

Input specification
The first line contains two numbers n and m where 1 ≤ n ≤ 500 and 2 ≤ m ≤ 1000. The next line will contain the original vector and the following m lines contain the testing vectors. The elements of the arrays are random numbers between -500 and +500.

Output specification
Show just one number j where 1 ≤ j ≤ m where jth array is the closest match to (or the same as) the original array.

Sample Input:
5 3
3.0 3.0 3.0 3.0 3.1
2.0 4.0 4.0 4.0 4.0
3.0 3.0 3.0 2.0 3.0
5.0 2.0 7.0 5.0 2.0

Sample Output:
2

Sample Output Explanation:
(3-2)² + (3-4)² + (3-4)² + (3-4)² + (3.1-4)² = 4.81
(3-3)² + (3-3)² + (3-3)² + (3-2)² + (3.1-3)² = 1.01
(3-5)² + (3-2)² + (3-7)² + (3-5)² + (3.1-2)² = 26.21
According to this calculations, the second vector has the smallest SSE distance.

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

www.contester.ru