|
|
Let those two partial derivatives equal to zero. Edited by author 24.12.2015 20:50 Edited by author 24.12.2015 20:50 Я переписала это на джаве, используя BigInteger и BigDecimal и получила AC. (Спасибо~) Вообще, если возникают большие числа, то сейчас такие задачи легче всего решаются на джаве. UPD: Не за что~ Edited by author 25.12.2015 03:26 Спасибо за советы.Очень бесят задачи,где многое зависит от сложной технической реализации. is it a some especial test? I think it's any test with N>1300. YES! if you use formula n*(n-1)*(2*n-1)/6 and n is long=> overflow when n > 1300! use this: long long n; //!!! Edited by author 08.10.2011 01:48 :) Thank you! Now AC. The problem was with precision. I've used 3 different ways to calculate simple linear regression and got 3 different wrong results. Please help. My email: Vitaly.Arbuzov@gmail.com Just google the method of least squares. You derive some formulas by hand, solve small linear system and get AC. i used nested ternary search on a and d but wa ( 24 when eps=1e-7 && 11 when eps<1e-7) i figured the function should be like that- f(a,d)=c1a^2+c2a+c3ad+c4d^2+c5d+c6 where c1=n && c4=n*(n-1)*(2*n-1)/6.0 here for n>1 the coefficient of a^2 and d^2 is always positive. so there should be only one(since quadratic) and low peak. so i thought ternary search would do. but why diff wa on diff value of eps. again, i found (by checking for tle) that there are high peaks as well. how can it be? perhaps, i am wrong right on the idea itself. please, guys help me find my bug. and, please tell me at least the method of solving. is it ternary search or some direct math formula or something else i am missing. if ternary search please tell me whether there is indeed high peaks and how did u deal with them... thanks in advance. Edited by author 21.03.2011 17:01 There is closed-form solution to the problem. Read some basic econometrics textbooks, "simple linear regression" section therein. thanks very much got ac. so simple :) Why in test 1 answer: 0.400 4.900 ? If b = 0.400, d = 4.900, ∑(ai − bi)^2 = 1,524. If b = 0.105263, d = 5.026316, ∑(ai − bi)^2 = 0,824 < 1,524. If b = 0.400, d = 4.900, ∑(ai − bi)^2 = 0.700 |
|
|