HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


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

Guest
• Review clarifications (1)

Volume problems

• 51182 - Count and Sum 2
• 51193 - The max element of k-th co...
• 51196 - The sum of two arrays
• 51197 - Even and odd Numbers
• Problem 3
• 50468 - Draw Matrix - 2
• 010. 50381 - Sum of the numbers
• 125. 50538 - Sum of kth Diagonal
• 140. 50599 - Sum of Squared Er...
• 15-SprPrE1-80. 50741 - DNA Distance
• 155. 50334 - What is the class aver...
• 185. 50784 - Top Growing Company
• 220. 50754 - Team Standings
• 230. 50286 - Remove Duplicates
• 250. 50448 - Paint Buckets
• 280. 50477 - Character Pyramids
• 50304 - Number Pattern

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