Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

EQUASOLV - Solving linear equations

Solve a system of N (1<N<7) linear equations of the form a1*x1+a2*x2+...+aN*xN=c. aand c are real numbers. A unique solution is assured.

Input

First line with number N, then N lines with a1, a2,...aN, c separated by space.

Output

The results for x1, x2,...xN one in each line. The floats should have a precision of 5 digits after the decimal-point.

Example

Input:
2
1 2 3
2 3 4

Output:
-1.00000
2.00000

Added by:HWK
Date:2011-02-28
Time limit:3.636s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: SCM qobi

hide comments
2014-05-14 18:42:30 Mitch Schwartz
@Dominique: Thanks, Ruby is fun and I've still got a lot to learn. :)
2014-05-13 20:57:51 Dominique VAILLANT
@Mitch: Although a Ruby fanatic for a long time, I'm very impressed by your wondering Ruby performances in many problems. What a pub for 'Matz'! :D
2011-10-04 16:29:14 HWK
@Jander: I guess you mean EQUASOLV, don't you? Is your E-mail adress in your user data correct? Then I'll send you the answer with a PM.
2011-10-04 12:17:13 Jander
@HWK: I'm intrigued as to what algorithm you're using then to solve this problem.
2011-10-04 11:54:39 HWK
Have a look at http://www.spoj.pl/problems/THREETWN/
My best solutions:
Ruby 278
Python 294
2011-10-04 11:08:55 HWK
@Jander: The quick and dirty Python clone with 171 bytes. Incredible! I'll also try it with Ruby but I guess it won't be shorter than my 'algo'.

Edit: Your algo in Ruby can't beat my one - 153<->144.

@hallvabo: 171 bytes uncompressed, compressed only a few less.

Last edit: 2011-10-04 11:38:13
2011-10-04 10:58:19 Jander
@HWK: I like the term "awesome" for that code. It's remarkably neat and self-contained. It was your comment about only using one '/' that got me thinking about alternative techniques. I'm certainly keeping this piece of code in my toolkit for other (production) matrix solving code.
2011-10-04 10:37:52 HWK
@hallvabo: I've seen Janders last awesome Perl solution. So I think a Python clone of it should be shorter than 236 bytes. I'll try it. Maybe I should try to convert it to Ruby too. :-)
2011-10-03 16:43:31 Hallvard Norheim Bø
HWK: can you improve Python too?
My best uncompressed solution is 236 bytes.
2011-10-03 12:36:53 HWK
Your 174 motivated me too to look at my solution again. Perhaps I'll find another improvement, but probably not 30 bytes.

Edit: Only 24 bytes saved. But 46 bytes less my first Ruby solution. :-)
To show the difference between our solutions: I use only one '+', '-' and '/'.

Last edit: 2011-10-03 15:07:05
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.