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



Sample input:
1 2 3 4 5 6
2 -1 -2 -1 -1 -5


Sample output:
-1.000 2.000
1.000 4.000

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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.))

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
# coding: utf-8

import sys


def Round(ip, dg):  # 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()

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin.readlines():
#for line in data.split('\n'):
	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))

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
# Aizu Problem 0004: Simultaneous Equation
#
import sys, math, os

# read input:
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 = str(round(det1 / det, 3))
    #y = str(round(det2 / det, 3))
    x = det1 / det + 0
    y = det2 / det + 0
    #if -.001 < x < 0:
    #    x = 0
    print("%.3f %.3f" % (x, y))

Submission status: Accepted

Solution code:

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))

Submission status: Accepted

Solution code:
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))
        
    

#testWriteFile()
SimultaneousEquation()

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
from __future__ import division
import sys
#   ad*x + bd*y = cd
# -)ad*x + ae*y = af
#         (bd-ae)*y = cd-af
# and so on...
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 # -0 towa...
    y = (c*d - a*f) / (b*d - a*e) + 0

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:

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) )

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
import sys
#from me.io import dup_file_stdin

#@dup_file_stdin
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()

Submission status: Accepted

Solution code:
while 1:
    def solver(a, b, c, d, e, f):
        answer = []

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

        else:
            m = a / d

            d = d * m
            e = e * m
            f = f * m

            y = (c - f)/(b - e)

            x = (c - b * y)/a

            if x == -0:
                x = 0
            if y == -0:
                y = 0

        answer.append(x)
        answer.append(y)
        return answer

    try:
        p_1, p_2, p_3, p_4, p_5, p_6 = map(float, raw_input().split())

        ans = []
        ans = solver(p_1, p_2, p_3, p_4, p_5, p_6)

        print "%.3f %.3f" % (ans[0], ans[1])

    except:
        break

Submission status: Accepted

Solution code:
# coding=utf-8

while True:
    try:
        number_list = list(map(float, input().split()))
    except EOFError:
        break
    det = number_list[0]*number_list[4] - number_list[1]*number_list[3]
    inverse_list = [number_list[4] / det, -number_list[1] / det, -number_list[3] / det, number_list[0] / det]

    x = inverse_list[0]*number_list[2] + inverse_list[1]*number_list[5]
    y = inverse_list[2]*number_list[2] + inverse_list[3]*number_list[5]

    print('{0:.3f} {1:.3f}'.format(x, y))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

while True:
	try:
		data = map(int, raw_input().split())
		a = data[0]
		b = data[1]
		c = data[2]
		d = data[3]
		e = data[4]
		f = data[5]

		x = (c*e-b*f)*1.0 / (a*e-b*d)
		if x == -0.000:
			x = 0.000
		if b != 0:
			y = (c-a*x)/b
		else:
			y = (f-d*x)/e
		if y == -0.000:
			y = 0.000

		print("{:.3f} {:.3f}".format(x,y))
	except EOFError:
		break

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
import sys
#import numpy as np

for i in sys.stdin:
    a,b,c,d,e,f=list(map(float, i.split()))
    #A=np.matrix([[a,b],[d,e]])
    #inv_A = np.linalg.inv(A)
    #P=np.matrix([[c],[f]])
    #X=inv_A.dot(P)
    y = (f-(d*c)/a)/((a*e-d*b)/a)
    x = (c-b*y)/a
    print("{0:.3f} {1:.3f}".format(x,y))

Submission status: Accepted

Solution code:
while True:
    try:
        a,b,c,d,e,f=map(int,raw_input().split())
        if a*d-b*c==0:
            print "not exist answer"
        else:
            x = (float((c*e-b*f)) / (a*e-b*d))+0
            y = (float((a*f-c*d)) / (a*e-b*d))+0
            print ('%.3f' % round(x,3)), ('%.3f' % round(y,3))
    except:
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def det(mat):
  t = 1 / (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0])
  a = t * mat[1][1]
  b = t * -1 * mat[0][1]
  c = t * -1 * mat[1][0]
  d = t * mat[0][0]
  return [[a, b], [c, d]]


for line in sys.stdin:
  try:
    a, b, c, d, e, f = [int(i) for i in line.split()]
    A = [[a, b], [d, e]]
    P = [c, f]
    detA = det(A)
    print("%.3lf %.3lf" % (detA[0][0] * P[0] + detA[0][1] * P[1], detA[1][0] * P[0] + detA[1][1] * P[1]))
  except:
    break

Submission status: Accepted

Solution code:
import math

def my_round(x,d=0):
    p = 10 ** d
    return float(math.floor((x * p) + math.copysign(0.5, x))) / p

class Equation():
    def __init__(self, a, b, c, d, e, f):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
        self.e = e
        self.f = f

    def calc(self):
        temp = (self.a * self.e - self.b * self.d)
        temp_a = (self.c * self.e - self.b * self.f)
        temp_b = (self.a * self.f - self.c * self.d)
        try:
            x = round(temp_a / temp+0., 3)
        except ZeroDivisionError:
            x = round(temp_a / 1.0, 4)

        try:
            y = round(temp_b / temp+0., 3)
        except:
            y = round(temp_b / 1.0, 4)


        return x, y


    def print(self):
        ans = self.calc()
        print("{0:.3f} {1:.3f}".format(ans[0], ans[1]))


def main():
    data = []

    while 1:
        try:
            n = input().split()

            a = float(n[0])
            b = float(n[1])
            c = float(n[2])
            d = float(n[3])
            e = float(n[4])
            f = float(n[5])

            data.append(Equation(a, b, c, d, e, f))

        except EOFError:
            break

    for num in data:
        num.print()

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    a,b,c,d,e,f = [float(i) for i in N[l].split()]
    x = (c*e-f*b)/(a*e-b*d)
    y = (f*a-c*d)/(a*e-b*d)
    print(format(x+0.0,'.3f'), format(y+0.0,'.3f'))

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 a,b,c,d,e,f=map(int,e.split())
 print("%-.3f %-.3f"%((c*e-b*f)/(a*e-b*d)+0,(c*d-a*f)/(b*d-a*e)+0))

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 a,b,c,d,e,f=map(int,e.split())
 print("%.3f %.3f"%((c*e-b*f)/(a*e-b*d)+0,(c*d-a*f)/(b*d-a*e)+0))

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 a,b,c,d,e,f=map(int,e.split())
 y=(c*d-a*f)/(b*d-a*e)
 print("%.3f %.3f"%((c-b*y)/a,y))

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    #print (str(round(x, 3))+' '+str(round(y, 3)))#dont int+str
    print("%.3f %.3f"%(x,y))

Submission status: Accepted

Solution code:
from sys import stdin
for line in stdin:
    a, b, c, d, e, f = map(float, line.split())
    anss = ['%.3f' % ((c * e - f * b) / (a * e - b * d)), '%.3f' % ((c * d - a * f) / (b * d - a * e))]
    for index, ans in enumerate(anss):
        if ans == '-0.000':
            anss[index] = '0.000'
    print(' '.join(anss))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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}".format(x+0.0, y+0.0))
    except:
        break

Submission status: Accepted

Solution code:
while True:
	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

Submission status: Accepted

Solution code:
while True:
    try:
        (a, b, e, c, d, f) = map(float, input().split())

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

        if abs(x) < 1e-4:
            x = 0.0
        if abs(y) < 1e-4:
            y = 0.0

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

    except EOFError:
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 a,b,c,d,e,f=map(int,e.split())
 y=(c*d-a*f)/(b*d-a*e)
 print(f'{(c-b*y)/a:.3f} {y:.3f}')

Submission status: Accepted

Solution code:
import sys
for i in sys.stdin:
    a, b, c, d, e, f = map(int, i.split())
    x = (c * e - b * f) / (a * e - b * d)
    y = (c * d - a * f) / (b * d - a * e)
    x = abs(x) if abs(x) < 10e-4 else x
    y = abs(y) if abs(y) < 10e-4 else y
    print("{:.3f} {:.3f}".format(x, y))

Submission status: Accepted

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

        detA = a * e - b * d
        detA1 = c * e - b * f
        detA2 = a * f - c * d

        print('{:.3f} {:.3f}'.format(detA1 / detA + 0, detA2 / detA + 0))
    except EOFError:
        break

Submission status: Accepted

Solution code:
# Vol0004.
import sys

def main():
    data = []
    lines = sys.stdin.readlines()

    for line in lines:
        data.append(line.split())  # スペース区切りで放り込む
    # ax + by = c, dx + ey = fの解は、
    # x = (ce - bf) / (ae - bd), y = (af - cd) / (ae - bd).
    # これをround(float, 3)すれば答えが出る。
    N = len(data)
    for i in range(N):
        for k in range(6):
            data[i][k] = int(data[i][k])
        det = data[i][0] * data[i][4] - data[i][1] * data[i][3]
        gx = data[i][2] * data[i][4] - data[i][1] * data[i][5]
        gy = data[i][0] * data[i][5] - data[i][2] * data[i][3]
        if det < 0:
            det = -det;
            if gx != 0: gx = -gx
            if gy != 0: gy = -gy
        print("{0:.3f}".format(gx / det) + " " + "{0:.3f}".format(gy / det))

if __name__ == "__main__":
    main()

# 補足、0.1とか0.22でも3桁目まで表示しないとWrongになる。
# 表示するにはprint("{0:.nf}".format(数))ってやる(nのところは桁数)。
# さらに、0を負の数で割ると表示が-0.000になってしまうのでそこの処理も重要。

Submission status: Accepted

Solution code:
def main():
    while 1:
        try:
            p = [float(x) for x in input().split()]
            x = (p[4]*p[2]-p[1]*p[5])/(p[0]*p[4]-p[1]*p[3])
            y = (p[2]-p[0]*x)/p[1]
        except:
            break
        if abs(x)<1e-4:
            x=0.0
        if abs(y)<1e-4:
            y=0.0
        print("{:.3f} {:.3f}".format(x,y))

main()

Submission status: Accepted

Solution code:
# AOJ 0004 Simultaneous Equation
# Python3 2018.6.9 bal4u

EPS = 0.0001
while True:
	try:
		a = list(map(float, input().split()))
		dd = a[0]*a[4]-a[3]*a[1]
		d1 = a[2]*a[4]-a[5]*a[1]
		d2 = a[0]*a[5]-a[3]*a[2]
		print("{0:.3f} {1:.3f}".format(d1/dd+EPS, d2/dd+EPS))
	except EOFError:
		break

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def inv(k):
    det = 1 / (k[0]*k[3] - k[1]*k[2])
    ret = [k[3] * det, -k[1] * det, -k[2] * det, k[0] * det]
    return ret

def dot(i, j):
    x = i[0] * j[0] + i[1] * j[1]
    y = i[2] * j[0] + i[3] * j[1]
    return [x,y]

def run():
    data = []
    for _data in sys.stdin:
        data.append(list(map(int, _data.split())))

    for _data in data:
        i = _data[:2] + _data[3:5]
        j = [_data[2],_data[5]]
        x, y = dot(inv(i), j)
        x, y = round(x, 3), round(y, 3)
        print('{0:.3f} {1:.3f}'.format(x,y))

if __name__ == '__main__':
    run()

Submission status: Accepted

Solution code:
while True:
    try:
        x = map(float, raw_input().split(" "))
        a = (x[2]*x[4]-x[1]*x[5])/(x[0]*x[4]-x[1]*x[3])
        b = (-x[3]*x[2]+x[0]*x[5])/(x[0]*x[4]-x[1]*x[3])
        
        if a == -0: a = 0
        if b == -0: b = 0
        
        print "%.3f %.3f" % (a, b)
    
    except EOFError:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        x = map(float, raw_input().split(" "))
        a = (x[2]*x[4]-x[1]*x[5])/(x[0]*x[4]-x[1]*x[3])
        b = (-x[3]*x[2]+x[0]*x[5])/(x[0]*x[4]-x[1]*x[3])
         
        if a == -0: a = 0
        if b == -0: b = 0
         
        print "%.3f %.3f" % (a, b)
     
    except EOFError:
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
while True:
    try:
        list = [float(x) for x in raw_input().split(" ")]
        x = (list[2]*list[4]-list[1]*list[5])/(list[0]*list[4]-list[1]*list[3])
        y = (list[0]*list[5]-list[2]*list[3])/(list[0]*list[4]-list[1]*list[3])
        if x == -0:
            x = 0
        if y == -0:
            y = 0
        print("%.3f %.3f" %(x, y))
    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys

def calc(a, b, c, d, e, f):
    tmp = a * e - b * d
    x = c * (e / tmp) + f * (-b / tmp)
    y = c * (-d / tmp) + f * (a / tmp)
    return (x, y)

for i in sys.stdin.readlines():
    i = i.strip()
    a, b, c, d, e, f = map(float, i.split())
    print "{0[0]:.3f} {0[1]:.3f}".format(calc(a, b, c, d, e, f))

Submission status: Accepted

Solution code:
#coding:UTF-8

while(True):
    try:
        n = map(float, raw_input().split())
        x = (n[2]*n[4] - n[5]*n[1]) / (n[0]*n[4] - n[3]*n[1])
        y = (n[2]*n[3] - n[5]*n[0]) / (n[1]*n[3] - n[4]*n[0])

        if x==-0:
            x=0
        if y==-0:
            y=0

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

    except Exception:
        break

Submission status: Accepted

Solution code:
import sys
import math
for i in sys.stdin.readlines():
    a,b,p,c,d,q= map(float, i.split())
    print "{:.3f} {:.3f}".format((d*p-b*q)/(a*d-b*c)+0,(-c*p+a*q)/(a*d-b*c)+0)

Submission status: Accepted

Solution code:
import sys
for x in sys.stdin.readlines():
    n = [float(y) for y in x.split()]

    print "%.3f %.3f" % ((n[2]*n[4]-n[1]*n[5])/(n[0]*n[4]-n[1]*n[3])+0,(n[5]*n[0]-n[2]*n[3])/(n[0]*n[4]-n[3]*n[1])+0)

Submission status: Accepted

Solution code:
#coding: utf-8
def solve(a, b, c, d, e, f):
    agn = a*e - b*d
    x = (e*c - b*f)/float(agn)
    y = (-d*c + a*f)/float(agn)
    if x == 0.: x = 0.
    if y == 0.: y = 0.
    print "%.3f %.3f" % (x, y)
    
while 1:
    try:
        a,b,c,d,e,f = map(float, raw_input().split())
        solve(a,b,c,d,e,f)
    except EOFError:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        a = map(float, raw_input().split(' '))
        x = (a[1]*a[5]-a[2]*a[4])/(a[1]*a[3]-a[0]*a[4])
        y = (a[2]*a[3]-a[0]*a[5])/(a[1]*a[3]-a[0]*a[4])
        if x == 0: 
            x = abs(x)
        if y == 0:
            y = abs(y)
        print '%.3f %.3f' % (x,y)
    except EOFError:
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
import sys

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

Submission status: Accepted

Solution code:
try:
 for r in iter(raw_input,0):a,b,c,d,e,f=map(float,r.split());g=a*e-b*d;print "%.3f %.3f"%((c*e-b*f)/g+1e-9,(a*f-c*d)/g+1e-9)
except:pass

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin:
    [a,b,c,d,e,f] = [float(x) for x in line.split()]
    x = (f-(c/b*e))/(d-(a/b*e))
    y = (f-(c/a*d))/(e-(b/a*d))
    print "%.3f %.3f" % (x if x else 0.0,y if y else 0.0)

Submission status: Accepted

Solution code:
data = []
try:
    while True:
        data.append(raw_input())

except EOFError:
    pass

for i in data:
    a, b, c, d, e, f = map(float, (i.split()))
    if (abs(a) <= 1000
        and abs(b) <= 1000
        and abs(c) <= 1000
        and abs(d) <= 1000
        and abs(e) <= 1000
        and abs(f) <= 1000):
        y = (a*f - c*d) / (a*e - b*d)
        x = (c - b*y) / a
        print "{:.3f} {:.3f}".format(x, y)

Submission status: Accepted

Solution code:
while True:
    try:
        a = map(float,raw_input().split())
        m = a[0]*a[4]-a[1]*a[3]

        x = (a[4]*a[2] - a[1]*a[5])/m
        y = (a[0]*a[5] - a[2]*a[3])/m

	if x == -0:
            x = 0
	if y == -0:
            y = 0

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

    except EOFError:
	break

Submission status: Accepted

Solution code:
while True:
    try:
        a, b, c, d, e, f = map(float, raw_input().split())
        a1 = (c*e-b*f)/(a*e-b*d)
        a2 = (a*f-c*d)/(a*e-b*d)
        if a1 == -0:
            a1 = 0
        if a2 == -0:
            a2 = 0
        print "{0:.3f} {1:.3f}".format(a1, a2)
    except EOFError:
        break

Submission status: Accepted

Solution code:
try :
  while True :
    (a,b,c,d,e,f) = map(float, raw_input().split())

    print "%.3f %.3f"%((c*e-b*f)/(a*e-b*d)+0, (a*f-c*d)/(a*e-b*d)+0)
except EOFError :
  pass

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

if __name__ == '__main__':

	while True:
		try:
			a, b, c, d, e, f = [float(num) for num in raw_input().split()]
			x = ((e*c)-(b*f))/((e*a)-(b*d))
			y = ((d*c)-(a*f))/((d*b)-(a*e))
		except:
			break

		if(x==-0):
			x=0
		if(y==-0):
			y=0
		
		print '%0.3f %0.3f' % (x , y)

Submission status: Accepted

Solution code:
import sys


def gcd(a, b):
    return gcd(b, a % b) if a % b else b


def lcm(a, b):
    return a * b / gcd(a, b)

for line in sys.stdin:
    data = map(int, line.split())
    a, b, c, d, e, f = data
    if a == 0:
        y = c * 1.0 / b
        x = (f - e * y) * 1.0 / d
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue
    if b == 0:
        x = c * 1.0 / a
        y = (f - d * x) * 1.0 / e
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue
    if d == 0:
        y = f * 1.0 / e
        x = (c - b * y) * 1.0 / a
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue
    if e == 0:
        x = f * 1.0 / d
        y = (c - a * x) * 1.0 / b
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue

    ix = lcm(a, d) / a
    jx = lcm(a, d) / d
    iy = lcm(b, e) / b
    jy = lcm(b, e) / e
    x = (c*1.0*iy - f*jy) / (a*iy - d*jy)
    y = (c*1.0*ix - f*jx) / (b*ix - e*jx)
    print "%.3f %.3f" % (round(x, 4), round(y, 4))

Submission status: Accepted

Solution code:
import sys
for i in sys.stdin:
    a,b,c,d,e,f=map(int,i.split())
    y=(d*c-a*f)*1.0/(d*b-a*e);
    print "%.3f %.3f"%((c-b*y)/a,y)