# Student name:    Jiaxin Lin
# Studnet number:  1311752
# MacId:           linj33
# Date:            2014/02/12


fname1=raw_input("Enter the first  file name: ")
fname2=raw_input("Enter the second file name: ")

infile1=open(fname1,'r')
infile2=open(fname2,'r')

data1=infile1.read()
data2=infile2.read()

Lx=data1.split()
Ly=data2.split()

infile1.close()
infile2.close()

n=len(Lx)

x1=0
y1=0
for i in range(n):
    Lx[i]=float(Lx[i])
    Ly[i]=float(Ly[i])
    x1=x1+Lx[i]
    y1=y1+Ly[i]
x=(1.0/n)* x1
y=(1.0/n)*y1
print x
print y

top=0
bot=0
for i in range(n):
    top=top+(Lx[i]-x)*(Ly[i]-y)
    bot=bot+ (Lx[i]-x)**2.0
b1=top/bot
b0=y-b1*x

    

print "Lx=",Lx
print "Ly=",Ly
print "b0=",b0

#Design Question:
# we can not slove b1 using one loop, becuase the valuse in the loop
# are imcomplete (the x and y value would be different) so tha the result of b1 would be different if you do it in a sepeate loop.


# text plan 1
# text i
# input:([5 5 6 9 3 1 4 7 8 2],
#        [1 2 3 4 5 6 7 8 9 0])
# Expected output: 2.75
# result: passed



# text plan 2
# text i
# input:([0,0,0,0,0,0,0,0,0,0,],
#   [1 2 3 4 5 6 7 8 9 0])

# Expected output: error
# result: passed
    

# text plan 3
# text i
# input:([9 8 7 6 5 4 3 2 1 0],
#        [1 2 3 4 5 6 7 8 9 0])
# Expected output: 6.54545454545
# result: passed
