10466 - How Far?

All about problems in Volume 104. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Moha
Experienced poster
Posts: 216
Joined: Tue Aug 31, 2004 1:02 am
Location: Tehran
Contact:

Post by Moha » Wed Jul 26, 2006 12:15 am

Can anybody post some testcase? this problem looks very easy but i have no idea why mine is WA!

Solaris
Learning poster
Posts: 99
Joined: Sun Apr 06, 2003 5:53 am
Location: Dhaka, Bangladesh
Contact:

Post by Solaris » Mon Oct 30, 2006 9:30 am

Hello shamim,

Can u plz post some test cases for which the cosine rule may not work ?? I am stuck ... My code seems to work for all the cases that I can think of :(

thnx in advance :)
Where's the "Any" key?

User avatar
shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim » Tue Oct 31, 2006 11:48 pm

Well, the best approach to solve this problem is to consider that the central body has a co-ordinate of (0,0).

This way, the co-ordinates of other planets can be found, hence thier distance from the central planet.

yiuyuho
A great helper
Posts: 325
Joined: Thu Feb 21, 2002 2:00 am
Location: United States
Contact:

Post by yiuyuho » Wed May 30, 2007 8:29 pm

Can someone tell me why the output for

Code: Select all

3 2
20 4
30 4
40 4
is

Code: Select all

20.0000 50.0000 90.0000
and not

Code: Select all

20.0000 10.0000 30.0000
???

what I am thinking is that as a planet revolve against its parent planet all of its child planet also get moved along (as suppose to staying at the right (initial position)).

So, If I have a case

3 2
1 4
1 1
1 1

I should get 1,2,3 and not 1, 0, 1

Is that incorrect logic?

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Wed May 30, 2007 9:07 pm

Yes, the description is a bit imprecise in it's definition of 'rotation period'. But you should consider the the rotation period of planet i as seen from planet i-1 relative to the stars. So if the periods of planet i and planet planet i+1 are the same, then planets i-1, i and i+1 are always on one line (the sun is planet 0).

Also the sample data is a bit unrealistic, because the radii increase going outward from the sun. Such a planetary system could never exist in reality. But that doesn't make the problem unsolvable, as long as you ignore planetary collisions.
The biggest problem with most problems is not how to solve the problem, but how to not solve what is not the problem.

andysoft
Experienced poster
Posts: 109
Joined: Sat Jun 23, 2007 9:53 pm
Location: Brest, BELARUS
Contact:

Post by andysoft » Fri Aug 10, 2007 10:07 am

Hi people!
I have already received too many AC PE verdicts by judge. And I want to know where my presentation can be wrong...

1) I output exactly one space between the output numbers for each planet.
2) I output NO spaces after the last planet.
3) I output NO blank like after the last test case
4) Here is my code (I will delete it as soon as possible, as it's almost AC, you know):

Code: Select all

program Project2;
{$APPTYPE CONSOLE}
var
  x,x0,y,y0,alpha: extended;
  i,ci,n: integer;
  gt: extended;
  r,t: array [1..100] of extended;
begin
  ci := 0;
  while not eof do
  begin
    readln (n,gt);
    if eof then break;
    for i:=1 to n do
      readln (r[i],t[i]);
    ci := ci + 1;

    if ci>1 then
    writeln;
    write (r[1]:0:4);
    alpha := (gt/t[1])*(2*pi);
    x0 := r[1]*cos(alpha);
    y0 := r[1]*sin(alpha);

    for i:=2 to n do
    begin
      write (' ');
      alpha := (gt/t[i])*(2*pi);
      x := r[i]*cos(alpha) + x0;
      y := r[i]*sin(alpha) + y0;
      write (sqrt(x*x+y*y):0:4);
      x0 := x;
      y0 := y;
    end;

  end

end.

Thanx in advance! :)

PS little joey, 1111 posts, nice :)
Now I lay me down to sleep...
my profile

yiuyuho
A great helper
Posts: 325
Joined: Thu Feb 21, 2002 2:00 am
Location: United States
Contact:

Post by yiuyuho » Fri Aug 10, 2007 11:32 pm

I believe you need an end-line after the last number you output: i.e.: the last character of the output is a "\n". I am not familiar with your language, but it seems you didn't put writeln after the last case.

andysoft
Experienced poster
Posts: 109
Joined: Sat Jun 23, 2007 9:53 pm
Location: Brest, BELARUS
Contact:

Post by andysoft » Tue Aug 14, 2007 3:06 pm

yiuyuho, man, it is unbelievable!!
I had my program written _as you said_ some time before, and it got AC PE. I posted here modified version, which didn't put "\n" after the last case (made specially), but it got AC PE. Now, I turned back to _as you said_ version, and it got ACCEPTED!!

Thank you!
Now I lay me down to sleep...
my profile

yiuyuho
A great helper
Posts: 325
Joined: Thu Feb 21, 2002 2:00 am
Location: United States
Contact:

Post by yiuyuho » Wed Aug 15, 2007 6:37 pm

you're welcome :-) May be you had some other spacing issue before....but anyways strange things happens and that's what makes programming fun !

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10466 - How Far?

Post by brianfry713 » Fri May 04, 2012 6:13 am

Input:

Code: Select all

3 5
20 5
30 5
40 5
10 10
20 1
30 2
40 3
50 4
60 5
70 6
80 7
90 8
100 9
110 10
AC output:

Code: Select all

20.0000 50.0000 90.0000
20.0000 50.0000 45.8258 40.0000 52.9150 26.4575 67.6432 119.3608 163.2869 202.1349
Check input and AC output for thousands of problems on uDebug!

Crocodile_009
New poster
Posts: 4
Joined: Thu Mar 08, 2012 8:11 am

Re: 10466 - How Far?

Post by Crocodile_009 » Tue Oct 23, 2012 12:50 pm

Code: Select all

AC :)

Post Reply

Return to “Volume 104 (10400-10499)”