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.
Для отправки решений необходимо выполнить вход.
|