Linear Regression Is Too Easy 1
Time limit1sMemory limit1024 MB
Given n points and an intercept b, find the slope a that makes the sum of (a*x_i + b - y_i) closest to 0, or print EZPZ if several slopes tie.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
문제
Yulim is confident about linear regression. During a MatKor club lecture on the topic, she was not paying attention. Dongwoo, who was the instructor at the time, did not like this, so he gave her a harder problem. In ordinary linear regression, given data , you find real numbers and that minimize , the sum of squared residuals. Dongwoo extended this to the sum of residuals raised to the power , , and asked for real numbers and that make this sum as close to as possible. Yulim found this too hard and asked for something easier. Dongwoo thought about it and added two conditions. Only the case is asked, and the -intercept is fixed so that only the slope must be found.
Help Yulim. For a given , find the real number that makes as close to as possible.
입력
The first line contains an integer (), the number of data points, and an integer (), the -intercept. Each of the next lines contains one point, given by integers and (). The same point may appear more than once.
출력
On the first line, print the value of that makes as close to as possible.
If the answer is an integer, print it as is. If the answer is a rational number that is not an integer, reduce it to an irreducible fraction (, , ) and print it in the form p/q. It can be proven that a rational achieving the closest value to always exists.
If more than one is possible, print EZPZ.