submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s980910776
p00004
Runtime Error
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) print("{0:.3f} {1:.3f}".format(X[0,0], X[1,0]))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s925082788
p00004
Runtime Error
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 = (c*e-b*f) / (a*e-b*d) y = (a*f-c*d) / (a*e-b*d) print ('%.3f' % round(x,3), ('%.3f' % round(y,3)) except: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s309809646
p00004
Runtime Error
def main(): while True: try: Array = list(map(int,input().split())) x = (Array[2]-(Array[1]/Array[4])*Array[5])/(Array[0]-(Array[1]/Array[4])*Array[3]) y = (Array[5]-Array[3]*x)/Array[4] except EOFError: break print("{0:.3f} {1:.3f} ".format(x,y)) if __name__ == '__main__': main()
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s005377108
p00004
Runtime Error
import itertools, sys d = {i: 0 for i in range(51)} for i in itertools.combinations_with_replacement(range(0,10), 4): if i[0] == i[1] == i[2] == i[3]: continue d[sum(i)] += 1 for i in map(int, sys.stdin): if i / 4 == 0: print(d[i]*4+1) else: print(d[i]*4)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s816478435
p00004
Runtime Error
import sys for e in sys.stdin: a, b, c, d, e, f = map(int, e.split()) a * (e*y-f) / d + b * y = c x = (e*y-f) / d print round(x, 3)+' '+round(y, 3)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s419085566
p00004
Runtime Error
import sys for e in sys.stdin: a, b, c, d, e, f = map(int, e.split()) a * (e*y-f) / d + b * y = c x = (e*y-f) / d print (round(x, 3)+' '+round(y, 3))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s383001316
p00004
Runtime Error
import sys for e in sys.stdin: a, b, c, d, e, f = map(int, e.split()) a * (-e*y+f) / d + b * y = c -x = (e*y-f) / d print (round(x, 3)+' '+round(y, 3))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s117395668
p00004
Runtime Error
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 = (e*y-f) / -d print (round(x, 3)+' '+round(y, 3))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s667607793
p00004
Runtime Error
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 (round(x, 3)+' '+round(y, 3))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s146889010
p00004
Runtime Error
import sys import numpy as np #np.set_printoptions(formatter={'float': '{: 0.3f}'.format}) #桁を揃える line = sys.stdin.readlines() #print(line) for i in line: cnt = 0 idx = 0 a = np.array([0.0, 0.0, 0.0, 0.0]) b = np.array([0.0, 0.0]) for k in list(map(float, i.split(" "))): if cnt == 2: b[0] = k idx -= 1 elif cnt == 5: b[1] = k else: a[idx] = k cnt += 1 idx += 1 #print(a, b) a = a.reshape(2, 2) x = np.linalg.solve(a, b) print('{0: 0.3f} {1: 0.3f}'.format(x[0], x[1]))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s573855141
p00004
Runtime Error
import sys import numpy as np #np.set_printoptions(formatter={'float': '{: 0.3f}'.format}) #桁を揃える line = sys.stdin.readlines() #print(line) for i in line: cnt = 0 idx = 0 a = np.array([0.0, 0.0, 0.0, 0.0]) b = np.array([0.0, 0.0]) for k in list(map(float, i.split(" "))): if cnt == 2: b[0] = k idx -= 1 elif cnt == 5: b[1] = k else: a[idx] = k cnt += 1 idx += 1 #print(a, b) a = a.reshape(2, 2) x = np.linalg.solve(a, b) print('{0: .3f} {1: .3f}'.format(x[0], x[1]))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s875431776
p00004
Runtime Error
import sys import numpy as np #np.set_printoptions(formatter={'float': '{: 0.3f}'.format}) #桁を揃える while True: line = sys.stdin.readline() if line is '': break #print(line) cnt = 0 idx = 0 a = np.array([0.0, 0.0, 0.0, 0.0]) b = np.array([0.0, 0.0]) for k in list(map(float, line.split(" "))): if cnt == 2: b[0] = k idx -= 1 elif cnt == 5: b[1] = k else: a[idx] = k cnt += 1 idx += 1 #print(a, b) a = a.reshape(2, 2) x = np.linalg.solve(a, b) print('{0: .3f} {1: .3f}'.format(x[0], x[1]))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s915968211
p00004
Runtime Error
import sys #import numpy as np # AOJではnumpy使えません #np.set_printoptions(formatter={'float': '{: 0.3f}'.format}) #桁を揃える while True: line = sys.stdin.readline() if line is '': break #print(line) a = list(map(float, line.split(" "))) #print(a) tmp = a[0] for i in range(0, 3): a[i] = a[i] * a[3] for i in range(3, 6): a[i] = a[i] * tmp #print(a) y = (a[2] - a[5]) / (a[1] - a[4]) x = (a[2] - a[1] * y) / a[0] print("{0:0.3f}".format(x), "{0:0.3f}".format(y))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s567439283
p00004
Runtime Error
import sys #import numpy as np # AOJではnumpy使えません #np.set_printoptions(formatter={'float': '{: 0.3f}'.format}) #桁を揃える lines = sys.stdin.readlines() for line in lines: a = list(map(float, line.split(" "))) tmp = a[0] for i in range(0, 3): a[i] = a[i] * a[3] for i in range(3, 6): a[i] = a[i] * tmp y = (a[2] - a[5]) / (a[1] - a[4]) x = (a[2] - a[1] * y) / a[0] print("{0:0.3f}".format(x), "{0:0.3f}".format(y))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s079075057
p00004
Runtime Error
import sys #import numpy as np # AOJではnumpy使えません #np.set_printoptions(formatter={'float': '{: 0.3f}'.format}) #桁を揃える lines = sys.stdin.readlines() for line in lines: a = list(map(float, line.split(" "))) tmp = a[0] for i in range(0, 3): a[i] = a[i] * a[3] for i in range(3, 6): a[i] = a[i] * tmp y = (a[2] - a[5]) / (a[1] - a[4]) x = (a[2] - a[1] * y) / a[0] print("{0:0.3f} {1:0.3f}".format(x, y))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s794959803
p00004
Runtime Error
import sys lines = sys.stdin.readlines() for line in lines: a = list(map(float, line.split(" "))) tmp = a[0] for i in range(0, 3): a[i] = a[i] * a[3] for i in range(3, 6): a[i] = a[i] * tmp y = (a[2] - a[5]) / (a[1] - a[4]) x = (a[2] - a[1] * y) / a[0] print("{0:0.3f} {1:0.3f}".format(x, y))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s262645081
p00004
Runtime Error
l = [[]] i = 0 y,x = [] while(True): try: l[i] = list(map(float, input().split())) i += 1 except: break for i in range(len(i)): a = l[i][0]/l[i][4] l[i] *= l[i] * a y[i] = (l[i][2]-l[i][5])/(l[i][1]-l[i][4]) x[i] = (l[i][2]-l[i][1]*y[i])/l[i][0]
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s469869019
p00004
Runtime Error
import numpy as np lst=[] while 1: try: lst.append(list(map(int, input().split()))) except EOFError: break for a in lst: A = np.array([[a[0],a[1]], [a[3],a[4]]]) b = np.array([a[2],a[5]]) x = np.linalg.solve(A, b) print(x)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s760769135
p00004
Runtime Error
import numpy as np while 1: try: a = list(map(float, input().split())) A = np.array([[a[0],a[1]], [a[3],a[4]]]) b = np.array([a[2],a[5]]) x = np.linalg.solve(A, b) print(x) except EOFError: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s337897652
p00004
Runtime Error
import sys import numpy as np while 1: line = sys.stdin.readline() if line is '': break a = list(map(float, input().split())) A = np.array([[a[0],a[1]], [a[3],a[4]]]) b = np.array([a[2],a[5]]) x = np.linalg.solve(A, b) print(x)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s015979155
p00004
Runtime Error
import sys import numpy as np while 1: line = sys.stdin.readline() if line is ' ': break a = list(map(float, input().split())) A = np.array([[a[0],a[1]], [a[3],a[4]]]) b = np.array([a[2],a[5]]) x = np.linalg.solve(A, b) print(x)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s958674838
p00004
Runtime Error
import numpy as np while 1: try: a = list(map(float, input().split())) A = np.array([[a[0],a[1]], [a[3],a[4]]]) b = np.array([a[2],a[5]]) x = np.linalg.solve(A, b) print(x) except: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s480166199
p00004
Runtime Error
import sys while 1: line = sys.stdin.readline() if line is ' ': break 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))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s443954602
p00004
Runtime Error
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}")
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s148324567
p00004
Runtime Error
import sys import numpy for i in sys.stdin: a, b, c, d, e, f = map(int, i.split()) print("{0:.3f} {1:.3f}".format(numpy.round((c * e - b * f) / (a * e - b * d), 3), numpy.round((c * d - a * f) / (b * d - a * e), 3)))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s276088111
p00004
Runtime Error
import sys import numpy for i in sys.stdin: a, b, c, d, e, f = map(int, i.split()) x = (c * e - b * f) / (a * e - b * d) x = abs(x) if x < 10e-4 else x print("{:.3f} {:.3f}".format(x, (c - x) / b))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s249126437
p00004
Runtime Error
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 x < 10e-4 else x y = abs(y) if y < 10e-4 else y print("{:.3f} {:.3f}".format(round(x,3), rount(y,3)))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s427758387
p00004
Runtime Error
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)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s031472624
p00004
Runtime Error
# 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): 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] print(str(round(gx / det, 3)) + " " + str(round(gy / det, 3))) if __name__ == "__main__": main()
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s938695192
p00004
Runtime Error
# Vol0004. import sys def main(): data = [] lines = sys.stdin.readlines() fp.close() 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になってしまうのでそこの処理も重要。
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s696215705
p00004
Runtime Error
def ans(a, b, c, d, e, f): x = ((e*c - b*f)/(a*e-b*d)) y = ((-d*x + f)/e) x = "%.3f" % x y = "%.3f" % y return x, y sets = [] while True: try: line = list(map(int, input().split())) if(line[0] == " "): break; else: sets.append(line) except IndexError: break for i in sets: x, y = ans(i[0],i[1],i[2],i[3],i[4],i[5]) print(x, y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s115125560
p00004
Runtime Error
def ans(a, b, c, d, e, f): x = ((e*c - b*f)/(a*e-b*d)) y = ((-d*x + f)/e) x = "%.3f" % x y = "%.3f" % y return x, y sets = [] while True: try: line = list(map(int, input().split())) if(line[0] == " "): break; else: sets.append(line) except IndexError: break for i in sets: x, y = ans(i[0],i[1],i[2],i[3],i[4],i[5]) print(x, y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s844581128
p00004
Runtime Error
while True: try: q = map(int,raw_input().split(" ")) y = (-1*q[0]*q[5] + q[2] * q[3]) / (-1*q[0] * q[4] + q[1] * q[3]) x = (q[5]-q[4]* y)/ q[3] if x == -0 or y == -0 : x == 0 y == 0 print "%.3f %.3f" % (x,y) except EOFError: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s659966677
p00004
Runtime Error
import sys for x in sys.stdin.readlines(): n = [int(y) for y in x.split()] print "%.3f %.3f" % ((n[2]*n[4]-n[1]*n[5])/(n[0]*n[3]-n[1]*n[3]),(n[5]*n[0]-n[2]*n[3])/(n[0]*n[4]-n[3]*n[1]))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s598512375
p00004
Runtime Error
while True: a = map(float, raw_input().split(' ')) if a[1]*a[3]-a[0]*a[4] == 0: print 'No answer' else: 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]) print '%.3f %.3f ' % (x,y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s715293989
p00004
Runtime Error
while True: a = map(float, raw_input().split(' ')) if a[1]*a[3]-a[0]*a[4] == 0: print 'No answer' else: 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)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s786587056
p00004
Runtime Error
while True: 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)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s710674563
p00004
Runtime Error
x = map(int,input().split(' ')) a = x[0] b = x[1] c = x[2] d = x[3] e = x[4] f = x[5] print round((c*e-b*f)/(a*e-d*b),4),round((c*d-a*f)/(b*d-a*e),4)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s470511508
p00004
Runtime Error
x = map(float,input().split(' ')) a = x[0] b = x[1] c = x[2] d = x[3] e = x[4] f = x[5] print round((c*e-b*f)/(a*e-d*b),4),round((c*d-a*f)/(b*d-a*e),4)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s090205221
p00004
Runtime Error
x = map(float,input().split(' ')) a = x[0] b = x[1] c = x[2] d = x[3] e = x[4] f = x[5] g = (c*e-b*f)/(a*e-d*b) h = (c*d-a*f)/(b*d-a*e) print round(g,4),round(h,4)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s309625368
p00004
Runtime Error
x = map(float,input().split(' ')) a = x[0] b = x[1] c = x[2] d = x[3] e = x[4] f = x[5] g = (c*e-b*f)/(a*e-d*b) h = (c*d-a*f)/(b*d-a*e) print round(g,3),round(h,3)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s775557315
p00004
Runtime Error
data = [] try: while True: data.append(raw_input()) except EOFError: pass for i in data: a, b, c, d, e, f = i.split() a, b, c, d, e, f = int(a), int(b), int(c), int(d), int(e), int(f) if abs(a) or abs(b) or abs(c) or abs(d) or abs(e) or abs(f) <= 1000: for j in range(-1000, 1001): if j != 0: y1 = (c - (a*j)) / float(b) y2 = (f - (d*j)) / float(e) if y1 == y2: print "{:.4f} {:.4f}".format(j, y1) break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s353071858
p00004
Runtime Error
data = [] try: while True: data.append(raw_input()) except EOFError: pass for i in data: a, b, c, d, e, f = i.split() a, b, c, d, e, f = int(a), int(b), int(c), int(d), int(e), int(f) if abs(a) or abs(b) or abs(c) or abs(d) or abs(e) or abs(f) <= 1000: for j in range(-1000, 1001): if j != 0: y1 = (c - (a*j)) / float(b) y2 = (f - (d*j)) / float(e) if y1 == y2: print "{:.3f} {:.3f}".format(j, y1) break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s725660881
p00004
Runtime Error
data = [] try: while True: data.append(raw_input()) except EOFError: pass for i in data: a, b, c, d, e, f = i.split() a, b, c, d, e, f = int(a), int(b), int(c), int(d), int(e), int(f) if abs(a) or abs(b) or abs(c) or abs(d) or abs(e) or abs(f) <= 1000: for j in range(-1000, 1001): if j != 0: y1 = (c - (a * j)) / float(b) y2 = (f - (d * j)) / float(e) if y1 == y2: print "{:.3f} {:.3f}".format(j, y1) break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s278644503
p00004
Runtime Error
data = [] try: while True: data.append(raw_input()) except EOFError: pass for i in data: a, b, c, d, e, f = i.split() a, b, c, d, e, f = int(a), int(b), int(c), int(d), int(e), int(f) if abs(a) or abs(b) or abs(c) or abs(d) or abs(e) or abs(f) <= 1000: for j in range(-1000, 1001): if j != 0: if (c - (a * j)) / float(b) == (f - (d * j)) / float(e): print "{:.3f} {:.3f}".format(j, (c - (a * j)) / float(b)) break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s378807113
p00004
Runtime Error
data = [] try: while True: data.append(raw_input()) except EOFError: pass for i in data: a, b, c, d, e, f = i.split() a, b, c, d, e, f = int(a), int(b), int(c), int(d), int(e), int(f) if abs(a) or abs(b) or abs(c) or abs(d) or abs(e) or abs(f) <= 1000: for j in range(-1000, 1001): y1 = (c - (a * j)) / float(b) y2 = (f - (d * j)) / float(e) if y1 == y2: print "{:.3f} {:.3f}".format(j, y1) break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s382379409
p00004
Runtime Error
data = [] try: while True: data.append(raw_input()) except EOFError: pass for i in data: a, b, c, d, e, f = i.split() a, b, c, d, e, f = int(a), int(b), int(c), int(d), int(e), int(f) if (abs(a) <= 1000 and abs(b) <= 1000 and abs(c) <= 1000 and abs(d) <= 1000 and abs(e) <= 1000 and abs(f) <= 1000): for j in range(-1000, 1001): y1 = (c - (a * j)) / float(b) y2 = (f - (d * j)) / float(e) if y1 == y2: print "{:.3f} {:.3f}".format(j, y1) break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s136531953
p00004
Runtime Error
e True: try: a = map(long,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
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s214080166
p00004
Runtime Error
import sys def solv(a,b,c,d,e,f): x = (c * e - b * f) / (a * e - b * d) y = (f - d * x) / e return (x, y) lis = sys.stdin.readlines() for line in lis: a, b, c, d, e, f = tuple(map((lambda x: float(x)), line.split(' '))) (x, y) = solv(a, b, c, d, e, f) print "%5.3f %5.3f" % (x, y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s755943373
p00004
Runtime Error
import sys def solv(a,b,c,d,e,f): x = (c * e - b * f) / (a * e - b * d) y = (f - d * x) / e return (x, y) lis = sys.stdin.readlines() for line in lis: a, b, c, d, e, f = tuple(map(float, line.split(' '))) (x, y) = solv(a, b, c, d, e, f) print "%5.3f %5.3f" % (x, y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s863639694
p00004
Runtime Error
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 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))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s764105194
p00004
Runtime Error
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 = line.split() a, b, c, d, e, f = data 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))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s320826900
p00004
Runtime Error
import sys def gcd(aa, bb): return gcd(bb, aa % bb) if aa % bb else bb def lcm(aa, bb): return aa * bb / gcd(aa, bb) for line in sys.stdin: data = line.split() a, b, c, d, e, f = data 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))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s493866624
p00004
Runtime Error
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 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))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s125266767
p00004
Runtime Error
while 1: a, b, c, d, e, f = map(int,input().split()) x = (c/b-f/e) / (a/b-d/e) y = (c/a-f/d) / (b/a-e/d) print("{:+.3f} {:+.3f}".format(x,y))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s144980213
p00004
Runtime Error
while 1: P = map(float,raw_input().split()) x = (P[2]*P[4]-P[1]*P[5])/(P[0]*P[4]-P[1]*P[3]) y = (P[2]*P[3]-P[0]*P[5])/(P[1]*P[3]-P[0]*P[4]) x = x if x else 0 y = y if y else 0 print "{:.3f} {:.3f}".format(x,y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s004681144
p00004
Runtime Error
data = raw_input() while data: a, b, c, d, e, f = map(int, data.split()) det = a*e-b*d x, y = float(e*c+(-b)*f)/det, float((-d)*c+a*f)/det print '%.3f %.3f' % (x, y) data = raw_input()
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s303487883
p00004
Runtime Error
while True: a, b, c, d, e, f = map(float, raw_input().split()) x = (c * e - b * f) / (a * e - d * b) y = (c * d - f * a) / (b * d - e * a) print ("{0:.3f} {1:.3f}".format(x + 0, y + 0))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s776170609
p00004
Runtime Error
while True: try: a, b, c, d, e, f = map(int, raw_input().split()) x = float(c*e - b*f)/(a*e - b*d) y = float(c*d - a*f)/(b*d - a*e) print ("%f %f" % (round(x,-3), round(y,-3)) except: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s901379636
p00004
Runtime Error
import sys for i in stdin.sys: a, b, c, d, e, f = map(float, raw_input().split()) x = float(c*e - b*f)/(a*e - b*d) y = float(c*d - a*f)/(b*d - a*e) if x == -0: x = 0 if y == -0: y = 0 print ("%.3f %.3f" % (x, y))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s253842544
p00004
Runtime Error
while 1: a, b, c, d, e, f = map(int, raw_input().split()) g = b / e x = (c - g * f) / (a - g) y = (c - a * x) / b print str(x) + " " + str(y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s097642153
p00004
Runtime Error
while 1: a, b, c, d, e, f = map(int, raw_input().split()) g = b / e x = (c - g * f) / (float(a) - g) y = (c - a * x) / float(b) print str(x) + " " + str(y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s990231557
p00004
Runtime Error
import sys while 1: try: a, b, c, d, e, f = map(int, raw_input().split()) g = b / e x = (c - g * f) / (float(a) - g) y = (c - a * x) / float(b) print str(x) + " " + str(y) except: EOFError sys.exit()
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s655322490
p00004
Runtime Error
import sys while 1: try: a, b, c, d, e, f = map(int, raw_input().split()) g = b / e x = (c - g * f) / (float(a) - g) y = (c - a * x) / float(b) print str(x) + " " + str(y) exception: EOFError sys.exit()
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s747276575
p00004
Runtime Error
import sys while 1: try: a, b, c, d, e, f = map(int, raw_input().split()) g = b / e x = (c - g * f) / (float(a) - g) y = (c - a * x) / float(b) print str(x) + " " + str(y) except EOFError: sys.exit()
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s787322030
p00004
Runtime Error
while 1: try: a, b, c, d, e, f = map(int, raw_input().split()) g = b / e x = (c - g * f) / (float(a) - g) y = (c - a * x) / float(b) print str(x) + " " + str(y) except EOFError: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s532186463
p00004
Runtime Error
while 1: try: a, b, c, d, e, f = map(float, raw_input().split()) g = b / e x = (c - g * f) / a - g) y = (c - a * x) / b print str(x) + " " + str(y) + "\n" except: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s696119348
p00004
Runtime Error
while 1: try: a, b, c, d, e, f = map(int, raw_input().split()) g = float(b) / float(e) float(x) = (c - g * f) / (a - g) float(y) = (c - a * x) / b print str(x) + " " + str(y) + "\n" except: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s456604543
p00004
Runtime Error
while 1: try: a, b, c, d, e, f = map(float, raw_input().split()) x = (c * e - b * f) * / (a * e - b * d) y = (f * a - c * d) * / (a * e - d * b) print str('%.3f' % x) + " " + str('%.3f' % y) + "\n" except: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s106350730
p00004
Runtime Error
while True: line = raw_input() if not line: break; lines = [int(x) for x in line.split(" ")] if lines.length == 6: x = 0 y = 0 (A1, B1, E1, A2, B2, E2) = lines if A1*B2==B1*A2 or A1*B2-A2*B1: break; x=1000*(E1*B2-B1*E2)/(A1*B2-B1*A2) y=1000*(E2*A1-E1*A2)/(A1*B2-A2*B1) print "%.3f %.3f" % (round(x)/1000, round(y)/1000)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s125155628
p00004
Runtime Error
while True: a,b,e,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) print '%d %d' % (x,y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s586332088
p00004
Runtime Error
while True: 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) print '%.3f %.3f' % (x,y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s836918580
p00004
Runtime Error
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.0: x = 0 if y == -0.0 y = 0 print '%.3f %.3f' % (x,y) except EOFError: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s124632260
p00004
Runtime Error
x=(e*d-b*f)/(a*d-b*c) y=(-e*c+a*f)/(a*d-b*c) print x print y
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s784309889
p00004
WA: Presentation Error
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): # squaren?????? 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(t), x))) return '\n'.join(r) + '\n' print(main())
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s031575188
p00004
WA: Presentation Error
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(t), x))) return '\n'.join(r) + '\n' print(main())
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s286432034
p00004
WA: Presentation Error
import sys import math r = sys.stdin.readlines() #r.pop(0) n = [[int(i) for i in (j.split())] for j in r] #n is list of each lines for l in n: y = (l[2]*l[3]-l[0]*l[5])/(l[1]*l[3]-l[0]*l[4]) x = (l[2]-l[1]*y)/l[0] print("{:.3f} {:.3f} ".format(x,y))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s415945611
p00004
WA: Presentation Error
import sys import math r = sys.stdin.readlines() n = [[int(i) for i in (j.split())] for j in r] #n is list of each lines for l in n: y = (l[2]*l[3]-l[0]*l[5])/(l[1]*l[3]-l[0]*l[4]) x = (l[2]-l[1]*y)/l[0] print("{:.3f} {:.3f} ".format(x,y))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s379884261
p00004
WA: Presentation Error
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))
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s081661194
p00004
WA: Presentation Error
while True: try: a = map(float, raw_input().split(' ')) if a[1]*a[3]-a[0]*a[4] == 0: print 'No answer' else: 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
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s138697210
p00004
WA: Presentation Error
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
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s015185707
p00004
WA: Presentation Error
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 = 0 if y == 0: y = 0 print '%.3f %.3f ' % (x,y) except EOFError: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s995251037
p00004
WA: Presentation Error
while 1: try: a, b, c, d, e, f = map(float, raw_input().split()) x = (c * e - b * f) / (a * e - b * d) y = (f * a - c * d) / (a * e - d * b) if x == -0.000: x = 0.000 if y == -0.000: y = 0.000 print str('%.3f' % x) + " " + str('%.3f' % y) + "\n" except: break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 &le; <var>a, b, c, d, e, f</var> &le; 1,000). You can suppose that given equation has a unique solution. </p> <H2>Input</H2> <p> The input consists of several data sets, 1 line for each data set. In a data set, there will be <var>a, b, c, d, e, f</var> separated by a single space. The input terminates with EOF. </p> <H2>Output</H2> <p> For each data set, print <var>x</var> and <var>y</var> separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places. </p> <H2>Sample Input 1</H2> <pre> 1 2 3 4 5 6 2 -1 -2 -1 -1 -5 </pre> <H2>Output for the Sample Input 1</H2> <pre> -1.000 2.000 1.000 4.000 </pre> <H2>Sample Input 2</H2> <pre> 2 -1 -3 1 -1 -3 2 -1 -3 -9 9 27 </pre> <H2>Output for the Sample Input 2</H2> <pre> 0.000 3.000 0.000 3.000 </pre>
s937099911
p00005
Wrong Answer
import sys for i in sys.stdin : m,n = map(int , i.split()) t1,t2=m,n while 1 : if m % n == 0 : break m , n = n , m % n a = n b = (t1 / a ) * t2 print "%d %d" % (a,b)
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s374927746
p00005
Wrong Answer
import sys for line in sys.stdin: a, b = map(int, line.split()) A, B = min(a, b), max(a, b) while True: mod = B % A if mod == 0: gcd = B / A break else: A, B = mod, A lcm = gcd * (a / gcd) * (b / gcd) print '%d %d' % (gcd, lcm)
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s723808020
p00005
Wrong Answer
while True: try: i=list(map(int,input().split())) i.sort() x=i[:] while True: if i[1]%i[0]!=0: i[0],i[1] = i[1]%i[0],i[1] else: print(i[0],int(x[0]*x[1]/i[0])) break; except: break;
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s664711126
p00005
Wrong Answer
import sys def main(): a = sys.stdin.readline() print ("Hello World") if __name__ == "__main__": main()
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s435656420
p00005
Wrong Answer
import sys def main(): tmp = sys.stdin.readline().split(" ") print ("Hello World") if __name__ == "__main__": main()
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s147281364
p00005
Wrong Answer
import sys def main(): tmp = sys.stdin.readline().split(" ") print (tmp[0]) if __name__ == "__main__": main()
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s015390918
p00005
Wrong Answer
import sys def main(): tmp = sys.stdin.readline().split(" ") print (tmp[0]) print (tmp[1]) if __name__ == "__main__": main()
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s799982375
p00005
Wrong Answer
import sys def main(): tmp = sys.stdin.readline().split(" ") print (str(int(tmp[0]))) print (str(int(tmp[1]))) if __name__ == "__main__": main()
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s045083332
p00005
Wrong Answer
import sys def main(): for line in iter(sys.stdin.readline, ""): print (line) if __name__ == "__main__": main()
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s277195747
p00005
Wrong Answer
import sys #最大公約数 def gcd(x, y): s = x / y r = x % y if r == 0: return y else: return gcd(y, r) #最小公倍数 def lcm(x, y): return x*y/gcd(x, y) def main(): #print ("a") for line in iter(sys.stdin.readline, ""): print (line) #tmp = sys.stdin.readline().split(" ") #print ("b") tmp = line.split(" ") a = int(tmp[0]) b = int(tmp[1]) #print ("a="+str(a)) #print ("b="+str(b)) #b = sys.stdin.readline() #print ("d") if a > b: c = a d = b else: c = b d = a print (str(gcd(c, d)) + " " + str(int(lcm(c,d)))) #tmp = sys.stdin.readline() #if len(tmp) == 1: # break #else: # tmp = tmp.split(" ") #print ("exit") if __name__ == "__main__": main()
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s008641712
p00005
Wrong Answer
while True: try: spam=map(int, input().split(' ')) spam = [i for i in spam] spam.sort() cola = spam[0] * spam[1] while True: if spam[0] == 0: print(spam[1]) print(int(cola/spam[1])) break pre = spam[0] spam[0] = spam[1] % spam[0] spam[1] = pre except: break
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s976630252
p00005
Wrong Answer
import sys def dividend(num, Q): a = Q b = (num / Q) * Q Q = num - (num / Q) * Q if num == b: aaa(a) dividend(num, Q) def aaa(greatest_common_divisor): least_common_multiple = num1 * num2 / greatest_common_divisor print('%s %s' % (greatest_common_divisor, least_common_multiple)) sys.exit() for input_line in sys.stdin: num1 = int(input_line.split(' ')[0]) num2 = int(input_line.split(' ')[1]) if num1 <= num2: dividend(num2, num1) elif num1 > num2: dividend(num1, num2)
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s654593618
p00005
Wrong Answer
import sys def dividend(num, Q): a = Q b = (num / Q) * Q Q = num - (num / Q) * Q if num == b: return aaa(a) dividend(num, Q) def aaa(greatest_common_divisor): least_common_multiple = num1 * num2 / greatest_common_divisor print('%s %s' % (greatest_common_divisor, least_common_multiple)) return for input_line in sys.stdin: num1 = int(input_line.split(' ')[0]) num2 = int(input_line.split(' ')[1]) if num1 <= num2: dividend(num2, num1) elif num1 > num2: dividend(num1, num2)
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s348863279
p00005
Wrong Answer
import sys def dividend(num, Q): a = Q b = (num / Q) * Q Q = num - (num / Q) * Q if num == b: aaa(a) return dividend(num, Q) def aaa(greatest_common_divisor): least_common_multiple = num1 * num2 / greatest_common_divisor print('%s %s' % (greatest_common_divisor, least_common_multiple)) return for input_line in sys.stdin: num1 = int(input_line.split(' ')[0]) num2 = int(input_line.split(' ')[1]) if num1 <= num2: dividend(num2, num1) elif num1 > num2: dividend(num1, num2)
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s384148001
p00005
Wrong Answer
def gcd(a, b): while b: a, b = b, a % b return a while True: try: a, b = map(int, (input.split())) except: break g = gcd(a, b) print(g, a * b // g)
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s752438284
p00005
Wrong Answer
def gcd(a, b): while b: a, b = b, a % b return a while True: try: a, b = map(int, input().split()) print(gcd(a, b), a * b // gcd(a, b)) except: break
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
s955372955
p00005
Wrong Answer
def gcd(a,b): return a if b==0 else gcd(b,a%b) def lcm(a,b): return a*b/gcd(a,b) while 1: try: a,b=map(int,raw_input().split()) except: break
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>