Solve the System of Equations
Statement
Goal
Given a system of N variables and N equations, find the value of each unknown in the system.Example:
N=2
3 5 3 => 3x+5y=3
0 5 0 => 0x+5y=0
You must find the values of the unknowns.
Solution:
x=1, y=0
So return: 1 0
NOTE: The data
Input
Line 1: N, the number of unknowns and equation lines to follow
Next N Lines: N+1 space separated integers, the N coefficients of the equation and the value (right hand side) of the equation
Next N Lines: N+1 space separated integers, the N coefficients of the equation and the value (right hand side) of the equation
Output
N values, either a whole number OR a reduced fraction
Constraints
0 < N <= 20
There is only one correct solution. The inputs will always be integers and zero terms will be included.
There is only one correct solution. The inputs will always be integers and zero terms will be included.
Example
Input
2 3 5 3 0 5 0
Output
1 0
Tags
Mathematics
Difficulty
Hard
Test cases
Starting Easy Test
Input
2
3 5 3
0 5 0
Output
1 0
Starting Easy Validator Validator
Input
2
5 8 21
0 5 10
Output
1 2
Still a System Test
Input
1
5 20
Output
4
Still a System Validator Validator
Input
1
1 2
Output
2
Fractions Test
Input
2
5 8 -7
3 4 5
Output
17 -23/2
Fractions Validator Validator
Input
2
4 4 9
2 7 5
Output
43/20 1/10
Getting Harder Test
Input
6
3 2 0 -12 15 8 0
1 10 0 8 5 2 9
2 14 -5 -14 -7 -6 6
15 9 10 -10 -4 -10 13
-3 1 8 -12 -5 -2 3
-14 -3 1 9 2 8 9
Output
2591816/184429 513748/184429 247027/184429 8238/26347 -3602420/184429 1640191/52694
Getting Harder Validator Validator
Input
6
1 1 1 1 1 1 1
1 2 3 4 5 6 7
-2 4 8 7 7 3 -12
5 4 7 9 6 2 0
6 7 1 9 4 3 8
-7 -4 5 -2 6 -9 1
Output
21494/9843 -725/579 -9618/3281 -10556/9843 2333/579 141/3281
Crazy Hard Test
Input
8
0 -6 4 -8 -8 -5 -5 1 -9
-5 -7 -1 -4 10 -3 -5 -3 -2
0 3 6 9 -5 -10 9 9 -8
6 -3 -3 -6 8 6 -7 -10 -10
3 7 -1 -7 5 2 7 -8 5
1 1 1 1 1 1 1 1 1
2 7 -2 0 -3 2 -8 -7 3
0 6 5 -3 6 -10 -9 3 -6
Output
-660556/297521 10561059/10115714 7583417/10115714 -1356997/5057857 -291339/5057857 15586219/10115714 715968/5057857 101237/1445102
Crazy Hard Validator Validator
Input
8
1 1 1 1 1 1 1 1 1
0 -1 -1 2 1 -1 2 -4 5
3 -1 -3 -3 0 0 -1 -1 4
-1 -3 -1 5 -3 1 -2 -1 -5
3 -2 -4 -1 4 -1 3 -3 3
5 1 1 5 -5 0 -1 -2 -1
-2 4 3 -3 2 4 -2 1 -1
-1 -1 2 3 -3 3 1 -5 0
Output
-118500/4781 36007/683 -308737/4781 28103/4781 -21864/683 89685/4781 169110/4781 46119/4781
Debugging Help Test
Input
3
0 0 5 8
0 8 9 -1
4 0 0 7
Output
7/4 -77/40 8/5
Debugging Help Validator Validator
Input
3
0 0 1 7
0 6 0 8
8 9 10 11
Output
-71/8 4/3 7
Incredibly Hard Test
Input
8
1 1 1 1 1 1 1 1 1
61 -45 0 42 -78 17 -58 -86 44
-53 -73 -95 5 -12 12 -60 -75 -39
-87 -28 -46 -52 -55 -6 -18 25 -93
29 -82 -51 91 -89 -35 -66 48 -8
41 -70 97 83 64 60 59 -9 -88
78 -81 -41 64 -30 32 -81 28 -80
59 -4 24 6 60 -34 -82 72 15
Output
-27195320359482/57109482057505 216067723244179/114218964115010 15608831964092/57109482057505 160970993588853/114218964115010 -2923645058461/57109482057505 -64404298242817/114218964115010 -93695441772279/114218964115010 -37849872897612/57109482057505
Incredibly Hard Validator Validator
Input
8
1 1 1 1 1 1 1 1 1
76 25 -60 -28 69 -37 -85 -15 -78
14 -12 -54 14 -3 -84 73 41 -88
98 -43 43 94 -93 89 34 -49 68
42 -66 5 -37 -56 -83 60 -31 -48
31 22 64 -85 -48 1 -91 -89 -12
70 -8 36 -36 -60 17 -3 -35 16
-38 -93 33 -13 76 48 -7 -55 -64
Output
5855922162349/12877243223734 -158494315808981/51508972894936 84107896405529/25754486447468 15683220526337/12877243223734 -70324756705021/51508972894936 -52878376722557/51508972894936 -50329803900271/12877243223734 280153274166777/51508972894936
Solution language
Solution
Stub generator input