Problem:
Simultaneous Equation Write a program which solve a simultaneous equation:   ax + by = c  dx + ey = f  The program should print x and y for given a , b , c , d , e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution. Input The input consists of several data sets, 1 line for each data set. In a data set, there will be a, b, c, d, e, f separated by a single space. The input terminates with EOF. Output For each data set, print x and y separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. Sample Input 1 1 2 3 4 5 6
2 -1 -2 -1 -1 -5 Output for the Sample Input 1 -1.000 2.000
1.000 4.000 Sample Input 2 2 -1 -3 1 -1 -3
2 -1 -3 -9 9 27 Output for the Sample Input 2 0.000 3.000
0.000 3.000

Solution (Python):
while True:
    try:raw=[float(i) for i in input().split(" ")]
    except:break
    a=raw[:3]
    b=raw[3:]
    yx=[]
    ed={0:1,1:0}
    for e in range(2):
        ab=[i*b[e] for i in a]
        ba=[i*a[e] for i in b]
        yx.append((ab[2]-ba[2])/(ab[ed[e]]-ba[ed[e]]))
    sisya=[i*10000-int(i*1000)*10 for i in yx]
    kekka=[True if i>4 else False for i in sisya]
    x="{0:.3f}".format(yx[1]+int(kekka[1])/1000)
    y="{0:.3f}".format(yx[0]+int(kekka[0])/1000)
    print(x+" "+y)

Solution (Python):


import sys

def solve_sim_equ(a, b, c, d, e, f):
    '''
    This function solves following equation.
    ax + by = c
    dx + ey = f
    '''
    if a==0 and d==0:
        if b==0 and e==0:
            return 0., 0.
        if b != 0:
            return 0., c/b+0.
        else:
            return 0., f/e+0.
    elif b==0 and e==0:
        if a != 0:
            return 0., d/a+0.
        else:
            return 0., a/d+0.

    if b == 0:
        a, d = d, a
        b, e = e, b
        c, f = f, c
    g = e / b
    x = (g*c - f) / (g*a - d)
    y = (c - a*x) / b
    return x+0., y+0.

def main():
    for line in sys.stdin:
        a,b,c,d,e,f = map(float, line.split())
        x, y = solve_sim_equ(a, b, c, d, e, f)
        print('{0:.3f} {1:.3f}'.format(x,y))

if __name__ == '__main__':
    main()

Solution (Python):
while True:
    try:
        a, b, c, d, e, f = map(int, input().split())
    except EOFError:
        break
    else:
        y = (f - c * d / a) / (e - b * d / a)
        x = c/a - b*y/a
        print('{0:.3f} {1:.3f}'.format(x, y))

Solution (Python):
import sys
for line in sys.stdin:
    a,b,c,d,e,f = list(map(int, line.split()))
    y = (f-(d*c)/a)/((a*e-d*b)/a)
    x = (c-b*y)/a
    print('%03.3f' % x,'%03.3f' % y)

Solution (Python):
import sys
for line in sys.stdin:
    a, b, c, d, e, f = map(float, line.split())
    b /= a
    c /= a
    a = 1.0
    e -= b*d
    f -= c*d
    d = 0
    f /= e
    e = 1.0
    c -= b*f
    print '%.3f %.3f'%(round(c, 3), round(f, 3))

Solution (Python):

inputs = []
while True:
  try:
    inputs.append(list(map(float,input().split())))
  except EOFError:
    break


for i in inputs:
  x=(i[2]*i[4]-i[1]*i[5])/(i[0]*i[4]-i[1]*i[3])
  y=(i[0]*i[5]-i[2]*i[3])/(i[0]*i[4]-i[1]*i[3])
  if x == -0.000:x=0
  if y == -0.000:y=0
  print("{0:.3f} {1:.3f}".format(x,y))

Solution (Python):
import sys
[[print("{0:.3f} {1:.3f}".format(round((t[2] - t[1] * (t[0] * t[5] - t[2] * t[3]) / (t[0] * t[4] - t[1] * t[3])) / t[0], 3), round((t[0] * t[5] - t[2] * t[3]) / (t[0] * t[4] - t[1] * t[3]), 3))) for t in [[int(y) for y in x.split()]]] for x in sys.stdin]

Solution (Python):
import sys
[print("{0:.3f} {1:.3f}".format((k[2] - k[1] * ((k[0] * k[5] - k[2] * k[3]) / (k[0] * k[4] - k[1] * k[3]))) / k[0], ((k[0] * k[5] - k[2] * k[3]) / (k[0] * k[4] - k[1] * k[3])))) for i in sys.stdin for k in [[int(float(j)) for j in i.split()]]]

Solution (Python):
while True:
    try:
        a, b, c, d, e, f = map(int, input().split())
        tb, tc = d*b, d*c
        te, tf = a*e, a*f
        y = (tc-tf)/(tb-te)
        x = (c-(y*b))/a
        print("{0:.3f} {1:.3f}".format(x, y))

    except:
        break

Solution (Python):
import sys

for line in sys.stdin:
    [a, b, c, d, e, f] = [float(x) for x in line.split()]
    determinant = a * e - d * b
    x = e * c - b * f
    y = -d * c + a * f
    x /= determinant
    y /= determinant
    if "%.3f" % (x) == "-0.000":
        result_x = "0.000"
    else:
        result_x = "%.3f" % (x)

    if "%.3f" % (y) == "-0.000":
        result_y = "0.000"
    else:
        result_y = "%.3f" % (y)

    print result_x, result_y

Solution (Python):
while True:
    try:
        a,b,c,d,e,f = list(map(float, input().split()))
    except EOFError:
        break
    print("{0:.3f} {1:.3f}".format((c*e-b*f)/(a*e-b*d)+0., (a*f-c*d)/(a*e-b*d)+0.))

Solution (Python):
while True:
    try:
        a,b,c,d,e,f = map(int,input().split())
        x = (c*e - f*b)/(a*e - b*d)
        y = (c*d - f*a)/(b*d - e*a)
        x = round(x,3)
        y = round(y,3)
        if x == -0.0:
            x = 0.0
        if y == -0.0:
            y = 0.0
        print("{0:.3f}".format(x),end = ' ')
        print("{0:.3f}".format(y))
    except EOFError:
        break

Solution (Python):
import sys
from math import fabs

if __name__ == '__main__':
    epsilon = 1e-9
    
    for line in sys.stdin:
        a, b, e, c, d, f = [int(x) for x in line.strip().split(' ')]
        x = 1/(a*d-b*c) * (d*e - b*f)
        y = 1/(a*d-b*c) * (-c*e + a*f)
        
        if fabs(x) < epsilon:
            x = 0.0
        if fabs(y) < epsilon:
            y = 0.0
        print('{0:.3f} {1:.3f}'.format(x, y))

Solution (Python):
while(1):
    try:
        [a,b,c,d,e,f]=map(int,raw_input().split())
        det=a*e-d*b
        x,y=(e*c-b*f)/float(det) ,(-d*c+a*f)/float(det)
        xs,ys='%.3f'%x,'%.3f'%y
        xs,ys=['0.000' if t=='-0.000' else t for t in [xs,ys]]
        print xs,ys
    except:
        break

Solution (Python):
while True:
    try:
        a,b,c,d,e,f=[float(i) for i in input().split()]
    except:
        break
    x=(c*e-b*f)/(a*e-b*d)
    y=(c*d-a*f)/(b*d-a*e)
    print("{0:.3f} {1:.3f}".format(x+0,y+0))

Solution (Python):


import sys

def solve_eq(a,b,c,d,e,f):
    x = ((e*c)-(b*f))/((a*e)-(b*d))
    y = ((a*f)-(c*d))/((a*e)-(b*d))
    if x == -0:
        x = 0
    if y == -0:
        y = 0
        
    sol = [x,y]
    return sol

array = []
for i in sys.stdin:
    array.append(i)

a = [0]*6
for i in range(len(array)):
    x = array[i].split()
    for i in range(len(x)):
        a[i] = float(x[i])

    ans = solve_eq(a[0],a[1],a[2],a[3],a[4],a[5])
    print("{0:0.3f}".format(ans[0]), "{0:0.3f}".format(ans[1]))

Solution (Python):
while 1:
    try:
        a,b,c,d,e,f=map(int,input().split())
        x=(c*d-a*f)/(b*d-a*e)
        print("{:.3f} {:.3f}".format((c-b*x)/a,x))
    except:break

Solution (Python):
while 1:
    try:a,b,c,d,e,f=map(int,input().split())
    except:break
    x=(c*d-a*f)/(b*d-a*e)
    print("%.3f %.3f"%((c-b*x)/a,x))

Solution (Python):
while True:
    try:
        a,b,c,d,e,f = map(int, input().split())
    except EOFError:
        break
    x = c/a - (b/a) * (a*f-c*d) / (a*e-b*d)
    y = (f*a - c*d) / (e*a - b*d)
    print('{:.3f} {:.3f}'.format(x, y))

Solution (Python):
import sys

def to_f(e):
  return float(e)

while True:
  line = sys.stdin.readline()
  if not line: break
  a,b,c,d,e,f = map(to_f, line.rstrip().split(" "))
  x = (c*e-b*f)/(a*e-d*b)
  y = (c*d-a*f)/(b*d-a*e)
  if x == 0:
    x = 0

  if y == 0:
    y = 0

  sys.stdout.write("{0:.3f}".format(x))
  sys.stdout.write(" ")
  print "{0:.3f}".format(y)

Solution (Python):
from sys import stdin
for l in stdin:
  a,b,c,d,e,f = map(int,l.split())
  x = round((c*e-b*f)/(a*e-b*d),3) + 0.000
  y = round((c*d-a*f)/(b*d-a*e),3) + 0.000
  print("%s %s"%("{0:.3f}".format(x),"{0:.3f}".format(y)))

Solution (Python):
def _round(x, d=0):
    p = 10 ** d
    return (x * p * 2 + 1) // 2 / p


try:
    while 1:
        a, b, c, d, e, f = list(map(int, input().split()))
        s = (a * e - b * d)
        x = e * c - b * f
        y = -c * d + a * f

        print("{:0.3f}".format(_round(x / s, 4)), "{:0.3f}".format(_round(y / s, 4)))
except:
    pass

Solution (Python):
import sys

nums = []


for line in sys.stdin:
    nums.append(line)

for i in range(len(nums)):
    input_line = nums[i].split(" ")
    a = float(input_line[0])
    b = float(input_line[1])
    c = float(input_line[2])
    d = float(input_line[3])
    e = float(input_line[4])
    f = float(input_line[5])

    x = (f * b - e * c)/(b * d - a * e)
    y = (c - a * x)/b

    
    print("{:.3f} {:.3f}".format(x+0,y+0))

Solution (Python):
import sys
dataset = sys.stdin.readlines()
 
for item in dataset:
    a, b, c, d, e, f = list(map(int, item.split()))
 
    y = (c * d - f * a)/(b * d - e * a)
    x = (c * e - b * f) / (a * e - b * d)
    if x == 0:
        x = 0
    print("{:.3f} {:.3f}".format(x, y))

Solution (Python):
while True:
    try:
        a, b, c, d, e, f = map(float, input().split())
        x = (c*e - b*f)/(a*e - b*d)
        y = (a*f - c*d)/(a*e - b*d)
        if x == 0.0:
            x = abs(x)
        if y == 0.0:
            y = abs(y)
        print('%.3f %.3f' %(x,y))
    except:
        break

Solution (Python):
while True:
    try:
        a, b, c, d, e, f = map(float, input().split())
        x = (c*e - b*f)/(a*e - b*d)
        y = (a*f - c*d)/(a*e - b*d)
        print('%.3f %.3f' %(x+0,y+0))
    except:
        break

Solution (Python):
import sys

for line in sys.stdin:
    a = list(map(float, line.split()))
    x = (a[4] * a[2] - a[1] * a[5]) / (a[0] * a[4] - a[1] * a[3]) + 0.0
    y = (a[0] * a[5] - a[3] * a[2]) / (a[0] * a[4] - a[1] * a[3]) + 0.0
    print("{:>.3f}".format(x) +" " + "{:>.3f}".format(y))

Solution (Python):
import sys

lines = sys.stdin.readlines()
for l in lines:
    nums = list(map(int, l.split()))
    A = [nums[0], nums[1], nums[3], nums[4]]
    B = [nums[2], nums[5]]
    detA = A[0]*A[3] - A[1]*A[2]
    inA = [A[3], -A[1], -A[2], A[0]]
    solutions = [n/detA+0.0 for n in [inA[0]*B[0] + inA[1]*B[1], inA[2]*B[0] + inA[3]*B[1]]]
    print("%.3f %.3f" % (solutions[0], solutions[1]))

Solution (Python):
import sys

lines = sys.stdin.readlines()
for line in lines:
    a, b, c, d, e, f = map(float, line.split())
    A = a * e - b * d
    if A == 0:
        break
    x = (c * e - b * f) / A
    y = (a * f - c * d) / A
    print('{:.3f} {:.3f}'.format(x+0, y+0))

Solution (Python):

import sys


while True:
    vals = sys.stdin.readline()
    if(vals is  None or vals.strip() == '' ):
        break
    a,b,c,d,e,f=list( map(float,vals.strip().split()))
    temp = a * e - d * b
    x = (c * e - b * f) / temp + 0.0
    y = (c * d - a * f) / -temp + 0.0
    print('%.3f %.3f' % (x,y))

Solution (Python):

import sys


while True:
    vals = sys.stdin.readline()
    if(vals is  None or vals.strip() == '' ):
        break
    a,b,c,d,e,f=list( map(float,vals.strip().split()))
    temp = a * e - d * b
    x = (c * e - b * f) / temp + 0.0
    y = (c * d - a * f) / -temp + 0.0
    print('%.3f %.3f' % (x,y))

Solution (Python):


import sys

def calc(nums):
    a = nums[0]
    b = nums[1]
    c = nums[2]
    d = nums[3]
    e = nums[4]
    f = nums[5]

    val = 1 / (a * e - b * d)

    x = val * (e * c - b * f) + 0.
    y = val * (- c * d + a * f) + 0.

    return  "%0.3f" % round(x, 3), "%0.3f" % round(y,3)


if __name__ == '__main__':

    lines = []

    for line in sys.stdin:
        if line == "\n":
            break
        else :
            lines.append(line)

    for line in lines:
        x,y = calc([ int(item) for item in line.split(" ")])

        print(str(x) + " " + str(y))

Solution (Python):
import sys
 
lines = sys.stdin.readlines()
for line in lines:
    a, b, c, d, e, f = map(float, line.split())
    if a * e - b * d == 0:
        break
    x = (e * c + (-b) * f)/(a * e - b * d)
    y = ((-d) * c + a * f)/(a * e - b * d)
    print('{:.3f} {:.3f}'.format(x+0, y+0))

Solution (Python):
import sys
eps=1e-9
for l in sys.stdin:
	a,b,c,d,e,f=map(float,l.split())
	x=(f-e*c/b)/(d-e*a/b)
	y=(a*x-c)/b
	print "%.3f %.3f" % (x+eps,-y+eps)

Solution (Python):
import sys
for line in sys.stdin:
    a, b, c, d, e, f = map(float, line.split())
    print('{0:.3f} {1:.3f}'.format(
        (e * c - f * b) / (e * a - d * b) + 0, (d * c - f * a) / (d * b - e * a) + 0))

Solution (Python):
import sys
  
lines = sys.stdin.readlines()
for line in lines:
    a, b, c, d, e, f = map(float, line.split())
    if a * e - b * d == 0:
        break
    x = (e * c + (-b) * f)/(a * e - b * d)
    y = ((-d) * c + a * f)/(a * e - b * d)
    print('{:.3f} {:.3f}'.format(x+0, y+0))

Solution (Python):


import sys
import os


for s in sys.stdin:
    a, b, c, d, e, f = list(map(int, s.split()))

    delta = a * e - b * d
    if delta == 0:
        break
    else:
        x = 1 / delta * (e * c - b * f)
        y = 1 / delta * (-d * c + a * f)
        print('{:.3f} {:.3f}'.format(x + 0, y + 0))

Solution (Python):
def r(val):
	v = val
	m = 1
	if val<0 : m=-1
	val = int(abs(val)*1000+0.51)*m
	return val/1000

def solve():
	[a,b,c,d,e,f] = list(map(int,input().split()))
	[x,y] = [e*c - b*f,a*f - c*d]
	di = a*e-b*d
	x /= di
	y /= di
	x = r(x)
	y = r(y)
	print("%.3f %.3f"%(x,y))


while True:
	try: solve()
	except: break

Solution (Python):
import sys

def mul4(v1, v2, v3, v4):
    return (v1 * v2) - (v3 * v4)

for i in sys.stdin:
    a, b, e, c, d, f = tuple(map(float, i.split()))
    det = mul4(a, d, c, b)
    print("{:.3f} {:.3f}".format(
        mul4(d, e, b, f) / det or 0.0,
        -mul4(c, e, a, f) / det or 0.0)
    )

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


class Matrix():
    def __init__(self, A):
        self.A = A
        self.row = len(A)
        self.col = len(A[0])

    def __iter__(self):
        return self.A.__iter__()

    def __getitem__(self, i):
        return self.A.__getitem__(i)

    def __add__(self, B):
        aa = self.A
        bb = B.A
        return Matrix([[aa[i][j] + bb[i][j] for j in range(self.col)] for i in range(self.row)])

    def __sub__(self, B):
        aa = self.A
        bb = B.A
        return Matrix([[aa[i][j] - bb[i][j] for j in range(self.col)] for i in range(self.row)])

    def __mul__(self, B):
        aa = self.A
        bb = B.A
        a = []
        for i in range(self.row):
            ai = aa[i]
            r = []
            for j in range(B.col):
                r.append(sum([ai[k] * bb[k][j] for k in range(self.col)]))
            a.append(r)
        return Matrix(a)

    def __truediv__(self, x):
        pass

    def lu(self):
        size = self.row
        T = copy.deepcopy(self.A)
        L = [[0]*size for _ in range(size)]
        U = [[0]*size for _ in range(size)]
        for i in range(size):
            for j in range(i,size):
                L[j][i] = T[j][i]
            for j in range(i,size):
                U[i][j] = T[i][j] / T[i][i]
            for j in range(i+1,size):
                for k in range(i+1,size):
                    T[j][k] -= L[j][i] * U[i][k]

        return Matrix(L),Matrix(U)

    def __str__(self):
        return self.A.__str__()

def solve_se(A, b):
    n = A.row
    L,U = A.lu()
    y = []
    for i in range(n):
        t = b[i]
        for k in range(i):
            t -= L[i][k] * y[k]
        y.append(t / L[i][i])

    x = [0] * n
    for i in range(n-1,-1,-1):
        t = y[i]
        for k in range(i+1,n):
            t -= U[i][k] * x[k]
        x[i] = t
    return x


def main():
    sa = [s for s in sys.stdin.read().split('\n') if s]
    r = []
    for s in sa:
        a,b,c,d,e,f = [int(c) for c in s.split()]
        A = Matrix([[a,b],[d,e]])
        B = [c,f]
        x = solve_se(A,B)
        r.append(' '.join(map(lambda t: '{:01.3f}'.format(1.0*t), x)))

    return '\n'.join(r)

print(main())

Solution (Python):
while True:
    try:
        a,b,c,d,e,f = map(float,raw_input().split())
        x = ( e*c - b*f ) / ( e*a - b*d )
        y = ( c*d - a*f ) / ( b*d - e*a )
        if x == -0.000:
            x = 0.000
        if y == -0.000:
            y = 0.000
        print '%.3f %.3f' % (x,y)
    except EOFError:
        break

Solution (Python):
while True :
    try :
        a, b, c, d, e, f = [int(_) for _ in input().split()]
        y = (a * f - c * d) / (a * e - b * d)
        x = (c - b * y) / a
        print('{0:0.3f} {1:0.3f}'.format(x, y))
    except : break

Solution (Python):

import sys

def determination(ls):
    return ls[0][0]*ls[1][1]-ls[0][1]*ls[1][0]

def inversion(ls):
    ret = []
    tmp = [x for x in ls]
    det = determination(tmp)
    
    if det == 0:
        return False
    else:
        tmp[0][0], tmp[1][1] = tmp[1][1], tmp[0][0]
        tmp[0][1] = tmp[0][1]*(-1)
        tmp[1][0] = tmp[1][0]*(-1)

    for x in tmp:
        ret.append(list(map(lambda x:x/det, x)))

    return ret

def dot(a,b):
    ret = []
    
    for x in a:
        ret.append(x[0]*b[0] + x[1]*b[1])

    return ret

def simueq(a,b):
    return dot(inversion(a), b)

def main():

    for line in sys.stdin:
        ls = list(map(int, line.split(' ')))
        a = [[ls[0], ls[1]], [ls[3], ls[4]]]
        b = [ls[2], ls[5]]
        
        answer = simueq(a,b)
        print('%.3f' % round(answer[0],3), '%.3f' % round(answer[1],3))
    
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    def get_inputs():
        li = []
        try:
            while True:
                li.append(input())
        except EOFError:
            return li

    def my_round(num, ndigits=3):
        num = num * 10**ndigits
        num = (num*2 + 1)//2
        num = num / 10**ndigits
        num = "{0:.3f}".format(num) 
        return num

    li = get_inputs()
    for str_num in li:
        tmp = str_num.split(" ")
        for i in range(len(tmp)):
            tmp[i] = int(tmp[i])
        a,b,c,d,e,f = tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]
        x = (c*e - b*f) / (a*e - b*d)
        x = my_round(x)
        y = (c*d - a*f) / (b*d - a*e)
        y = my_round(y)
        print("{} {}".format(x,y))
    return None


if __name__ == '__main__':
    main()

Solution (Python):
while True:
	try:
		a,b,c,d,e,f = map(float, input().split())
		z = a*e - b*d
		if z != 0:
			y = (a*f - c*d) / z
			x = (c*e - b*f) / z
			print("{:.3f} {:.3f}".format(x+0,y+0))
	except:
		break

Solution (Python):
import sys

lines = []
for line in sys.stdin:
    num = line.split(" ")
    a, b, e, c, d, f = int(num[0]), int(num[1]), int(num[2]), int(num[3]), int(num[4]), int(num[5])
    x = (e*d-b*f)/(a*d-b*c)
    y = (a*f-e*c)/(a*d-b*c)
    if x == -0.0:
        x = 0.0
    if y == -0.0:
        y = 0.0
    print("{0:.3f} {1:.3f}".format(x,y))

Solution (Python):
import fileinput
if __name__ == "__main__":
    for line in fileinput.input():
        v = [int(i) for i in line.split(" ")]
        x = (v[2] * v[4] - v[1] * v[5]) / (v[0] * v[4] - v[1] * v[3])
        y = (v[2] * v[3] - v[0] * v[5]) / (v[1] * v[3] - v[0] * v[4])
        if -0.0005 < x <= 0:
            x = 0.000
        if -0.0005 < y <= 0:
            y = 0.000
        print(format(x, ".3f"), format(y, ".3f"))

Solution (Python):
import sys
for line in sys.stdin:
    a,b,c,d,e,f = map(int,line.strip().split(' '))
    x = (c*e - b*f) / (a*e - b*d)
    y = (c*d - a*f) / (b*d - a*e)
    print("{:.3f} {:.3f}".format(x+0, y+0))

Solution (Python):
import sys
for line in sys.stdin:
    a, b, c, d, e, f = map(float, line.split())
    x = (c*e - b*f) / (a*e - b*d)
    y = (a*f - c*d) / (a*e - b*d)
    if x == -0.0:
        x = 0
    if y == -0.0:
        y = 0
    print('{:.3f} {:.3f}'.format(x, y))

Solution (Python):
import sys
for line in sys.stdin:
    a, b, c, d, e, f = map(int, line.split())
    x = (c*e - b*f) / (a*e - b*d)
    y = (a*f - c*d) / (a*e - b*d)
    if x == -0.0:
        x = 0
    if y == -0.0:
        y = 0
    print('{:.3f} {:.3f}'.format(x, y))

Solution (Python):
while True:
	try:
		a,b,c,d,e,f = map(int,input().split())
	except:
		break
	y = (c * d - a * f) / (b * d - a * e)
	x = (c - b * y) / a
	xs = str(round(x,3))
	ys = str(round(y,3))
	while xs[::-1].find(".") < 3:
		xs += "0"
	while ys[::-1].find(".") < 3:
		ys += "0"
	print(xs,ys)

Solution (Python):
import sys

for line in sys.stdin:
	a, b, c, d, e, f = map(float, line.split())
	x = (c * e - f * b) / (a * e - d * b)
	y = (c * d - f * a) / (b * d - e * a)
	if x == 0:
		x = 0
	if y == 0:
		y = 0
	print('{0:.3f} {1:.3f}'.format(x, y))

Solution (Python):



import sys
import math

def my_round(x):
    xx = 1000*x
    f, i = math.modf(xx)
    
    if f < 0.0 and f <= -0.5:
        i -= 1
    if f >= 0.0 and f >= 0.5:
        i += 1
    return i/1000 + 0

def main():
    for line in sys.stdin:
        a, b, c, d, e, f = map(float, line.split())

        det = a*e - b*d
        x = ( e*c - b*f) / det
        y = (-d*c + a*f) / det

        xr = my_round(x)
        yr = my_round(y)
        print("{:.3f} {:.3f}".format(xr, yr))

if __name__ == "__main__": main()

Solution (Python):
def main():
	import sys

	w = []

	for line in sys.stdin:
		w = list(map(float, line.split()))
		solve(w)

def solve(w):
	x = (w[2]*w[4]-w[1]*w[5]) / (w[0]*w[4]-w[1]*w[3])
	y = (w[2]*w[3]-w[0]*w[5]) / (w[1]*w[3]-w[0]*w[4])
	x = round(x, 3)
	y = round(y, 3)
	if x == -0.0:
		x = 0.0
	if y == -0.0:
		y = 0.0
	print('{0:.3f} {1:.3f}'.format(x, y))

if __name__ == '__main__':
	main()

Solution (Python):
import sys

for line in sys.stdin:
    a,b,c,d,e,f=list(map(int,line.split()))
    x=(c*e-b*f)/(a*e-b*d)
    y=(a*f-c*d)/(a*e-b*d)
    print("{0:.3f} {1:.3f}".format(x+0.0,y+0.0))

Solution (Python):
while True:
    try:
        a, b, c, d, e, f = map(int, input().split())
    except:
        break
    y = (c*d-f*a) / (b*d-e*a)
    x = (c - b*y) / a
    print("{:.3f} {:.3f}".format(x, y))

Solution (Python):
import sys
for i in sys.stdin:
	a,b,c,d,e,f=list(map(float,i.split()))
	y=(d*c-a*f)/(d*b-a*e)+0
	x=(e*c-b*f)/(e*a-d*b)+0
	print("{:.3f} {:.3f}".format(x,y))

Solution (Python):
import sys

for line in sys.stdin:
    a, b, c, d, e, f = list(map(float, line.split()))
    x = (c * e - b * f) / (a * e - b * d)
    y = (a * f - c * d) / (a * e - b * d)
    print("{0:.3f} {1:.3f}".format(x + 0., y + 0.))

Solution (Python):
try:
    s = []
    while True:
        l = list(map(float, input().split()))
        x = (l[2] * l[4] - l[5] * l[1]) / (l[0] * l[4] - l[3] * l[1])
        y = (l[2] - l[0] * x) / l[1]
        if x == -0 and y == -0:
            x = abs(x)
            y = abs(y)
        elif x == -0:
            x = abs(x)
        elif  y == -0:
            y = abs(y)
        else:
            pass
        
        x_2 = "{0:.3f}".format(x)
        y_2 = "{0:.3f}".format(y)
        print(str(x_2) + " " + str(y_2))
except EOFError:
    pass

Solution (Python):
while 1:
    try:
        a,b,c,d,e,f=[int(i) for i in input().split()]

        y=float((c*d-f*a)/(b*d-e*a))
        x=float((c-b*y)/a)
        print("{0:.3f}".format(x),"{0:.3f}".format(y))
    except EOFError:
        break

Solution (Python):


import sys


def Round(ip, dg):  
    ip = ip * 10**dg
    if(ip-int(ip) >= 0.5):
        return (int(ip) + 1)/10**dg
    else:
        return int(ip)/10**dg


for i in sys.stdin:
    try:
        line = [int(k) for k in i.split(" ")]
        a = line[0]
        b = line[1]
        c = line[2]
        d = line[3]
        e = line[4]
        f = line[5]
        print("{0:.03f}".format(Round((c*e-f*b)/(a*e-d*b), 3)) + " " + "{0:.03f}".format(Round((a*f-d*c)/(a*e-d*b), 3)))
    except:
        exit()

Solution (Python):
import sys
  
for s in list(sys.stdin):
    a,b,e,c,d,f = list(map(float,s.split()))
    base = a*d-b*c
    x = e*d-b*f
    y = a*f-e*c
    print('%.3f %.3f' % (x/base+0,y/base+0))

Solution (Python):
import sys
  
for s in list(sys.stdin):
    a,b,e,c,d,f = list(map(float,s.split()))
    base = a*d-b*c
    x = e*d-b*f
    y = a*f-e*c
    print('%.3f %.3f' % (x/base+0,y/base+0))

Solution (Python):
import sys

for s in list(sys.stdin):
    a,b,e,c,d,f = map(float,s.split())
    base = a*d-b*c
    x = e*d-b*f
    y = a*f-e*c
    print('%.3f %.3f' % (x/base+0,y/base+0))

Solution (Python):
import sys

def main():
    """ ????????? """
    istr = sys.stdin.read()
    wi = istr.splitlines()
    for i in wi:
        a, b, c, d, e, f = list(map(int,i.split()))
        z = (a * e - b * d)
        x = round((c * e - b * f) / z, 3) + 0.0
        y = round((a * f - c * d) / z, 3) + 0.0
        print("{0:.3f} {1:.3f}".format(x,y))

if __name__ == '__main__':
    main()

Solution (Python):
import sys
for line in sys.stdin.readlines():

	a,b,c,d,e,f = [int(s) for s in line.split()]
	x = (c*e-b*f) / (a*e-b*d)
	y = (c*d-a*f) / (b*d-a*e)
	if round(x,3) == 0.0:
		x = 0.0
	if round(y,3) == 0.0:
		y = 0.0
	print('{0:.3f} {1:.3f}'.format(x,y))

Solution (Python):
import sys


def calc(a, b, c, d, e, f):

    a2 = a * d
    b2 = b * d
    c2 = c * d

    d2 = d * a
    e2 = e * a
    f2 = f * a

    t1 = c2 - f2
    t2 = b2 - e2

    y = t1 / t2
    x = (c - b * y) / a

    return x, y


for line in sys.stdin:
    datas =line.split()
    if (len(datas)):

        li = list(map(int, datas)) 
        a = li[0]
        b = li[1]
        c = li[2]
        d = li[3]
        e = li[4]
        f = li[5]

        x, y = calc(a, b, c, d, e, f)

        print("%.3f %.3f" % (round(x, 3), round(y, 3)))

    else:
        break

Solution (Python):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


for line in sys.stdin:
    a, b, c, d, e, f = [int(_) for _ in line.split()]
    det = a * e - b * d
    det1 = c * e - b * f
    det2 = a * f - c * d
    
    
    x = det1 / det + 0
    y = det2 / det + 0
    
    
    print("%.3f %.3f" % (x, y))

Solution (Python):

import sys
import math

r = sys.stdin.readlines()


n = [[float(i) for i in (j.split())] for j in r] 
    
for l in n:
    y = (l[2]*l[3]-l[0]*l[5])/(l[1]*l[3]-l[0]*l[4])+0
    
    x = (l[2]*l[4]-l[5]*l[1])/(l[0]*l[4]-l[3]*l[1])+0
    
    print("%.3f %.3f" %(x, y))

Solution (Python):
import sys
def SimultaneousEquation():
    for line in sys.stdin:
        a,b,c,d,e,f=map(float,line.split())
        y=(c*d-f*a)/(b*d-e*a)
        x=(c-b*y)/a
        print("{0:.3f} {1:.3f}".format(x,y))
        
    


SimultaneousEquation()

Solution (Python):
import fileinput as fi
if __name__ == "__main__":
    for line in  fi.input():
        a,b,c,d,e,f = list(map(int,line.strip().split()))
        x1 = (c*e -b*f)
        x2= (a*e - b*d)
        if x2< 0:
            x1 = -x1
            x2= -x2
        y1 = (c*d - a*f)
        y2= (b*d - a*e)
        if y2 <0:
            y1= -y1
            y2 = -y2
        print("%.3f %.3f" % (x1/x2,y1/y2))

Solution (Python):
try:
    while True:
        a,b,c,d,e,f=map(float, input().split())
        x=(c*e-b*f)/(a*e-b*d)
        y=(a*f-c*d)/(a*e-b*d)
        if x==0:
            x=0
        if y==0:
            y=0
        x=round(x,3)
        y=round(y,3)
        print("{0:.3f}".format(x),"{0:.3f}".format(y))
except EOFError:
    pass

Solution (Python):
try:
    while True:
        a,b,c,d,e,f=map(float, input().split())
        x=(c*e-b*f)/(a*e-b*d)
        y=(a*f-c*d)/(a*e-b*d)
        if x==0:
            x=0
        if y==0:
            y=0
        x=round(x,3)
        y=round(y,3)
        print("{0:.3f}".format(x),"{0:.3f}".format(y))
except EOFError:
    pass

Solution (Python):
try:
    while True:
        a,b,c,d,e,f=map(float, input().split())
        x=(c*e-b*f)/(a*e-b*d)
        y=(a*f-c*d)/(a*e-b*d)
        if x==0:
            x=0
        if y==0:
            y=0
        print("{0:.3f}".format(round(x,3)), "{0:.3f}".format(round(y,3)))
except EOFError:
    pass

Solution (Python):
try:
    while True:
        a,b,c,d,e,f=map(float, input().split())
        x=(c*e-b*f)/(a*e-b*d)
        y=(a*f-c*d)/(a*e-b*d)
        if x==0:
            x=0
        if y==0:
            y=0
        print("{0:.3f}".format(round(x,3)), "{0:.3f}".format(round(y,3)))
except EOFError:
    pass

Solution (Python):
import sys
for line in sys.stdin:
    a, b, c, d, e, f = map(int, line.split())
    n1, n2 = -b/a*d, c/a*d
    n1 += e
    n2 = -n2 + f
    y = n2/n1
    x = (c - b*y)/a
    print("{:.3f} {:.3f}".format(x, y))

Solution (Python):
import math
import sys

while True:
	try:
		a,b,c,d,e,f = map(float, input().split())
		if a*e == b*d:
			continue
		x = (c*e - b*f)/(a*e - b*d)
		y = (c*d - a*f)/(b*d - a*e)
		if x == 0:
			x = 0
		if y == 0:
			y = 0
		print('{0:.3f} {1:.3f}'.format(x,y)) 
	except EOFError:
		break

Solution (Python):
from __future__ import division
import sys




while True:
    try:
        a, b, c, d, e, f = map(float, raw_input().split())
    except:
        break
    x = (c*e - b*f) / (a*e - b*d) + 0 
    y = (c*d - a*f) / (b*d - a*e) + 0

    print "{:.3f} {:.3f}".format(round(x,3), round(y,3))

Solution (Python):
import sys

d = sys.stdin.readline()
while d:
    a,b,c,d,e,f = map(int,d.split())
    inv = 1/(a*e - b*d)
    iA = [[e,-b],[-d,a]]
    B = [c,f]
    sol = list()
    for i in range(2):
        tmp = 0
        for j in range(2):
            tmp += inv*iA[i][j] * B[j]
        sol.append(tmp)
    print("%.3f %.3f"%(sol[0],sol[1]))

    d = sys.stdin.readline()

Solution (Python):
t = 0
while t == 0:	
	try:
		a,b,e,c,d,f = [int(i) for i in input().split()]
	except:
		break
	else:
		x = (d*e - b*f) / (a*d - b*c) + 0
		y = (a*f - c*e) / (a*d - b*c) + 0
		print("{0:.3f}".format(x) + " " + "{0:.3f}".format(y))

Solution (Python):
x = []
y = []
while True:
    try:
        a, b, p, c, d, q = map(int, input().split())
        x.append((d*p-b*q)/(a*d-b*c))
        y.append((a*q-c*p)/(a*d-b*c))
    except EOFError:
        break

for i in range(len(x)):
    print("{:.3f} {:.3f}".format(x[i]+0, y[i]+0))

Solution (Python):

while True:
  try:
    data = raw_input()
  except EOFError:
    break

  a,b,c,d,e,f = map(float, data.split())

  x = ( b*f - e*c ) / ( b*d - a*e )

  y = ( c*d - a*f ) / ( b*d - a*e )

  if x == -0.0:
    x = 0

  if y == -0.0:
    y = 0

  print "%.3f %.3f" % ( round(x,3), round(y,3) )

Solution (Python):
import sys
from decimal import Decimal
from fractions import Fraction

def main():

    input_strings = sys.stdin.readlines()
    for matrix_string in input_strings:
        matrix = list(map(Fraction, list(matrix_string.split())))
        if matrix[0] == 0:
            matrix = matrix[3:] + matrix[:3]
        matrix = list(map(lambda x: x / matrix[0], matrix[:3])) + matrix[3:]
        matrix = matrix[:3] + list(map(lambda x: x[1] - matrix[3] * x[0], zip(matrix[:3], matrix[3:])))
        matrix = matrix[:3] + list(map(lambda x: x / matrix[4], matrix[3:]))
        matrix = list(map(lambda x: x[0] - matrix[1] * x[1], zip(matrix[:3], matrix[3:]))) + matrix[3:]
        matrix = list(map(float, matrix))
        matrix = list(map(Decimal, matrix))
        matrix = list(map(lambda x: x.quantize(Decimal('.001'), rounding='ROUND_HALF_UP'), matrix))

        print('%.3f %.3f' % (matrix[2], matrix[5]))
main()

Solution (Python):
import sys
import math
def simeq(a,b,c,d,e,f):
    return ((c*e-b*f)/(a*e-b*d)+0,((a*f-c*d)/(a*e-b*d))+0)

if __name__ == '__main__':
    for line in sys.stdin:
        (a,b,c,d,e,f) = map(float,line.split())
        (x,y) = simeq(a,b,c,d,e,f)
        print("{:.3f} {:.3f}".format(round(x,3),round(y,3)))

Solution (Python):
import sys



def solve():
    for line in sys.stdin:
        a,b,c,d,e,f=map(float,line.split(' '))
        print("{:.3f} {:.3f}".format((c*e-b*f)/(a*e-b*d)+0,(c*d-a*f)/(b*d-a*e)+0))
solve()