HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Arithmetic > problem:


50599 - Sum of Squared Error (SSE) Distance

Guest
• Review clarifications (1)

Section problems

• 50579 - Pentagonal Numbers
• 50581 - The roots of a quadratic eq...
• 50582 - Number of digits
• 50583 - Max of 3 numbers
• 50584 - Total invoice amount
• 50585 - Inner Product
• 50587 - Modular Conversion
• 50595 - Sum of the numbers
• 50599 - Sum of Squared Error (...
• 50609 - Long division
• 50633 - The prime factors
• 50634 - Perfect numbers
• 50635 - Decomposition into terms
• 50637 - Number systems
• 50650 - Prime numbers
• 50652 - Prime Factorization
• 50653 - Long Divide

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