Show all threads Hide all threads Show all messages Hide all messages |
WA2: "Impossible." with a dot | KostyaRychkov | 1294. Mars Satellites | 3 Jul 2020 03:16 | 1 |
If it is impossible to find out the distance from C to D, then write "Impossible." and not "Impossible" |
If you have WA 3 | Toshpulatov (MSU Tashkent) | 1294. Mars Satellites | 9 Feb 2020 20:11 | 1 |
use cout.precision(0) and cout << sqrt(ans) * 1000.0 << endl; Edited by author 09.02.2020 20:13 |
Did anyone derive the solution? | Aditya Paliwal | 1294. Mars Satellites | 14 Oct 2017 15:29 | 1 |
I just used some identities and solved some equations to get the answer. Pretty sure I wouldn't be able to solve if I did not have access to the net and that is pretty lame :/ Was anybody able to solve by deriving the solution themselves? If yes, then please share! I want to learn the approach! ^_^ |
To admins: please, add tests! | Dmitri Belous | 1294. Mars Satellites | 19 Sep 2017 13:56 | 3 |
My simple wrong program skips necessary mathematical checks, but it got AC. 1 20 5 5 Answer: Impossible. (Wrong solution skipped the check of cos(∠DAC) bounds; a cosinus must be from -1 to 1) 5 7 4 7 Answer: Impossible. (Wrong solution skipped the check of the order of satelites; the test case is from the task subscription, I've just changed the positions of A and B satelites). Unfortunately both tests are incorrect. "Impossible" means only "ambiguous" in this problem. |
Hi to everyone. Why its WA3 | Bartenal | 1294. Mars Satellites | 29 Apr 2016 15:29 | 1 |
import math values = raw_input().split(' ') a = float(values[0]) b = float(values[1]) c = float(values[2]) d = float(values[3]) if (math.fabs(a*b-c*d)<0.001): print "Impossible."
j = 0.0 x = a**2 + b**2 #DC**2(1) y = c**2 + d**2 #DC**2(2) x1 = - 2 * a * b y1 = - 2 * c * d l = math.fabs(x - y) r = math.fabs(x1 - y1) if r == 0: False else: j = l / r #cos res = a**2.0 + b**2.0 - 2.0 * a * b *j #DC**2 res = math.sqrt(res)*1000 #DC print "Distance is %(res)d km." %{"res": res} Edited by author 29.04.2016 15:30 Edited by author 29.04.2016 16:01 |
Test #6 | Pisnyachevsky Nikolai | 1294. Mars Satellites | 6 Feb 2016 11:10 | 3 |
Test #6 Pisnyachevsky Nikolai 7 Apr 2006 23:30 I took into account all recomendations from discussions of this problem, but still have WA#6. Does anybody know this test? I had the same WA#6. Try to use double for each variable. It helped me. also, you can use this: (long long)answer |
WA 10 | Felix_Mate | 1294. Mars Satellites | 25 Dec 2015 15:34 | 1 |
WA 10 Felix_Mate 25 Dec 2015 15:34 |
Why WA 10? | Felix_Mate | 1294. Mars Satellites | 1 Dec 2015 22:46 | 1 |
var AD,AC,BD,BC,X,Y:int64; CD:real;
BEGIN read(AD,AC,BD,BC);
X:=AD*AC-BD*BC; Y:=AD*AC*(BD*BD+BC*BC)-BD*BC*(AD*AD+AC*AC); if(X=0)or(Y*X<0) then write('Impossible.') else begin write('Distance is '); CD:=1000*sqrt(Y/X); write(CD:0:0,' km.'); end; END. |
Some coments | Leniwwwiy | 1294. Mars Satellites | 28 Jun 2014 23:07 | 2 |
* don't use double (use float) * don's foget fabs() I used double without problem! And there are solution without fabs(), your comment are not helpful |
THe same code ,G++ 4.7.2 C++11->WA G++ 4.7.2->AC why? | binwin20 | 1294. Mars Satellites | 31 Mar 2013 09:12 | 1 |
1294. Mars Satellites G++ 4.7.2 Accepted 0.015 345 KB 1294. Mars Satellites G++ 4.7.2 C++11 Wrong answer 1 0.015 369 KB |
whats in 3 test?? what s wrong? | ivan | 1294. Mars Satellites | 13 Nov 2012 03:22 | 2 |
my code c# using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace kyrsach1294 { class Program { static int Main(string[] args) { int a,b,c,d; string[] dlins = Console.ReadLine().Split(' '); a = int.Parse(dlins[0]); b = int.Parse(dlins[1]); c = int.Parse(dlins[2]); d = int.Parse(dlins[3]); if (a * b==c * d) { { Console.WriteLine("Impossible."); return 0; } }
double s,s1,s2; s1 = c * d / (c * d - a * b);
s2 = a * b / (c * d - a * b); s = s1*a*a+s1*b*b-s2*c*c-s2*d*d; if (s < 0) { Console.WriteLine("Impossible."); return 0; } int answer;
s = Math.Sqrt(s) * 1000; answer = Convert.ToInt32(s); Console.WriteLine("Distance is "+answer+" km."); return 0; } } } please help Edited by author 03.04.2012 22:40 Hi, guy. Don't use Convert.ToInt32 for answer, it's wrong. You should go some other way. For example, first, I used double instead of int, and a small value EPS = 1e-9. if(Math.Abs(a*b - c*d) < EPS) { Console.WriteLine("Impossible."); return; } Second, I don't used : if (s < 0) { Console.WriteLine("Impossible."); return 0; } It's not necessary. I passed without this. Third, you should approximate on another way. Convert.ToInt32 don't work correct, but I found the simple trick : bool flag = false; x = Math.Sqrt((a*b*(c*c + d*d) - c*d*(a*a + b*b)) / (a*b - c*d)); int y = ((int)(x * 10000.0)) % 10; if (y >= 5) flag = true; int ans = (int)(x * 1000.0); if (flag == true) ++ans; Console.WriteLine("Distance is {0} km.", ans); I hope that I helped you. If you will get WA again and again I can send you correct code on your email. 4615234 03:01:21 13 ноя 2012 ZamNick 1294. Марсианские спутники C# Accepted 0.109 2 096 КБ |
Why should I got WA2? It seems very easy to solve. | z | 1294. Mars Satellites | 7 Apr 2012 23:45 | 5 |
{$N+} Program Mars_satellites; Var cos_,x,a,b,c,d:Double; Begin Readln(a,b,c,d); If (a*b-c*d)=0 Then Begin Write('Impossible'); End Else Begin cos_:=a*a+b*b-c*c-d*d; cos_:=cos_/(2*a*b-2*c*d); x:=a*a+b*b-2*a*b*cos_; x:=sqrt(x); x:=round(1000*x); Write('Distance is ',x:0:0,' km.'); End; End. Hi, your program has two mistakes, first one is (a*b-c*d)=0, equlity cannot be tested with doubles that way, you should use Abs(a*b-c*d)<e instead, where e is very small value, in this case e=0.01 is enough; second mistake is the formula I think, try to solve the math part of this problem again. If you want I can send you my AC program ( or just it's formula ). ...то выведите "Impossible.", иначе... "Impossible{.}" who said the numbers were double? they are small integers... And the formula is very good... |
Please, help me. WA3 (( | tm15xSat | 1294. Mars Satellites | 26 Feb 2012 18:36 | 1 |
what is wrong??? #include <iostream> #include <cmath> using namespace std; int main () { int a, b, c, d; cin >> a >> b >> c >> d; if (a*b == c*d) { cout << "Impossible."; return 0; } double s; s = (c*d*a*a + c*d*b*b - a*b*c*c - a*b*d*d)/(c*d-a*b); if (s < 0) { cout << "Impossible."; return 0; } int ans; s = (sqrt(s) * 1000); if (s - (int)s < 0.5) ans = (int)s; else ans = (int)s + 1; cout << "Distance is " << ans << " km."; return 0; } Edited by author 26.02.2012 18:37 |
WA2 --------------> "Impossible." not "Impossible" | zxy_snow | 1294. Mars Satellites | 14 Sep 2011 08:39 | 1 |
|
Hints to solvers! | Alone | 1294. Mars Satellites | 29 Jul 2011 10:36 | 1 |
1. ABCD is the only allowed order (not ADBC) 2. Use cosinuse rule, and if you get division by zero... so sutuation is impossible 3. Be carefull while checking zero... use integers or compare with EPS 4. printf("... %.0lf ...", res) 5. Check your output format twice good luck |
Note to the solution of the test number 3 | Alflex | 1294. Mars Satellites | 25 Feb 2011 21:49 | 1 |
The printing of the answer in C++ should be, e.g., in the form: cout << "Distance is " << setiosflags(std::ios_base::fixed) << setprecision(0) << 1000.0*sqrt(dist) << " km."; where dist is double value. You don't need to round off the answer with the help of some functions. |
To all C++ coders having problems with T#3 or so... | Intelligent_Design | 1294. Mars Satellites | 6 Mar 2010 17:33 | 3 |
In this problem,rounding the double value to the nearest integer appeares to be the most tricky part of the whole problem. If you want to guarantee correct rounding, do it yourself with floor() and ceil(). At least,as it happened to me.:) You can do it like this: printf("%.0lf\n", res); You are absolutely right: ``cout << int(r)'' is WA, while ``printf("Distance is %.0lf km.", r);'' is AC. |
To JUDGES! | BlackShark | 1294. Mars Satellites | 9 Jan 2009 21:25 | 2 |
(or to people who put the text of the problem here). The text of the problem not seems to be correct. You can't say 'geostationery orbit', when you mean Mars. You should say 'marsostationary orbit' or something like that. Edited by author 09.01.2009 12:42 Fixed Vladimir Yakovlev (USU) 9 Jan 2009 21:25 |
wa3 ((( | Egor Stepanov [mikroz] | 1294. Mars Satellites | 13 Nov 2008 19:20 | 1 |
wa3 ((( Egor Stepanov [mikroz] 13 Nov 2008 19:20 What's wrong??? my code: #include <cstdio> #include <cmath> int main() { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d);
if (a * b == c * d) { printf("Impossible.\n"); } else { double cos = (a * a * 1.0 + b * b - c * c - d * d) / (2 * a * b - 2 * c * d); double x = a * a * 1.0 + b * b - 2 * a * b * cos;
if (x < 0) printf("Impossible.\n"); else printf("Distance is %d km.\n", (int)(sqrt(x) * 1000)); } } |
Easy Problem but needs Attention | Seyyed Mehran Kholdi | 1294. Mars Satellites | 6 Jun 2008 19:22 | 1 |
It's a very easy problem bur needs much attention. I got WA many times just for small things: 1) "Impossible." its not "Impossible" 2) Input data order 3) Precision 4) Not writing "Distance is..." |