问题描述
给定一个二元一次方程组,形如:
a * x + b * y = c;
d * x + e * y = f;
x,y代表未知数,a, b, c, d, e, f为参数。
求解x,y
a * x + b * y = c;
d * x + e * y = f;
x,y代表未知数,a, b, c, d, e, f为参数。
求解x,y
输入格式
输入包含六个整数: a, b, c, d, e, f;
输出格式
输出为方程组的解,两个整数x, y。
样例输入
例:
3 7 41 2 1 9
3 7 41 2 1 9
样例输出
例:
2 5
2 5
数据规模和约定
0 <= a, b, c, d, e, f <= 2147483647
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d= sc.nextInt();
int e = sc.nextInt();
int f = sc.nextInt();
int y = (a*f-c*d)/(a*e-b*d);
int x = (c-b*y)/a;
System.out.println(x+" "+y);
}
}