10221 - Satellites

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

Moderator: Board moderators

htl
Experienced poster
Posts: 185
Joined: Fri Jun 28, 2002 12:05 pm
Location: Taipei, Taiwan

10221 - Satellites

Post by htl »

I get this code WA. I just use cos low to figure out the answer. What's wrong with the code?
[c]
#include<stdio.h>
#include<math.h>
#include<string.h>
#define PI 3.14159265358979323846
void main(void)
{
double a,s;
char data[4];
while(scanf("%lf %lf %s",&s,&a,data)!=EOF)
{
if(strcmp(data,"deg")==0)
printf("%.6lf ",(6440+s)*(a*PI/180));
else
printf("%.6lf ",(6440+s)*(a/60*PI/180));
if(strcmp(data,"min")==0)
a/=60;
printf("%.6lf\n",sqrt(2*(6440+s)*(6440+s)*(1-cos(a*PI/180))));
}
}
[/c]
Picard
Learning poster
Posts: 96
Joined: Mon Jun 24, 2002 1:22 pm
Location: Hungary
Contact:

Post by Picard »

it's a bit tricky. for example: what is the arc distance for 240 degrees?
htl
Experienced poster
Posts: 185
Joined: Fri Jun 28, 2002 12:05 pm
Location: Taipei, Taiwan

Post by htl »

Yep, I found that if a>180 my code will give the wrong answer. I've got it AC.
Terrible
New poster
Posts: 2
Joined: Mon Aug 19, 2002 8:27 am
Contact:

10227 WA

Post by Terrible »

Should anyone have some sample inputs and output..
Should I consider the angle greater than 360....

Should anyone replay me? Thanks
koola
New poster
Posts: 2
Joined: Wed Sep 25, 2002 10:41 am

10221 a easy problem,but why wrong answer?

Post by koola »


#include<iostream.h>
#include<math.h>
#include<stdio.h>
#define pi 3.1415926535897932384626433832795
void main()
{
double arc,chord;
char ch[4];
long s;
double a;
long r;
r = 6440;
while(cin>>s>>a>>ch)
{
if(ch[0]=='m') a = a/60;

while (a >= 360.0)
{
a -= 360.0;
}
a = pi*a/180;
chord = sin (a/2)*(r+s)*2;
if(chord<0) chord = chord*(-1);
arc = (r+s) * a;
if(arc<0) arc = arc*(-1);
printf("%.6lf %.6lf\n",arc,chord);
}
}
uzioriluzan
New poster
Posts: 27
Joined: Thu Feb 14, 2002 2:00 am

Re: 10221 a easy problem,but why wrong answer?

Post by uzioriluzan »

try using pi = acos(-1). Also there is no a>360 in the input. What happens if a > 180? Try using cos instead of sin to determine chord.
Regards!
koola wrote: #include<iostream.h>
#include<math.h>
#include<stdio.h>
#define pi 3.1415926535897932384626433832795
void main()
{
double arc,chord;
char ch[4];
long s;
double a;
long r;
r = 6440;
while(cin>>s>>a>>ch)
{
if(ch[0]=='m') a = a/60;

while (a >= 360.0)
{
a -= 360.0;
}
a = pi*a/180;
chord = sin (a/2)*(r+s)*2;
if(chord<0) chord = chord*(-1);
arc = (r+s) * a;
if(arc<0) arc = arc*(-1);
printf("%.6lf %.6lf\n",arc,chord);
}
}
Culter
New poster
Posts: 2
Joined: Mon Jul 28, 2003 3:21 pm
Location: Zagreb

10221 - Satelites

Post by Culter »

Problem is very easy, but there is always WA. Could anybody help me?

Code: Select all

#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#define pi 3.1415926535897932384626433832795
using namespace std;

int main() {
    long double s,a,l,d;
    string m;
    while (cin >> s >> a >> m) {
          s+=6440;
          if (m=="min") a/=60;
          l=s*pi*a/180;
          a=a*pi/180;
          d=2*s*sin(a/2);
          printf("%.6lf %.6lf\n",l,d);
    }
    return 0;
}
Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post by Per »

Think about angle > pi. You have a mistake there.
b3yours3lf
New poster
Posts: 44
Joined: Wed Aug 14, 2002 3:02 am

Post by b3yours3lf »

why my code give wa?

[c]#include<stdio.h>
#include<string.h>
#include<math.h>
#define pi 3.1415926535897932384626433832795

main()
{
double s, a, r=6440.0;
double arc, chord;
char unit[5];
#ifndef ONLINE_JUDGE
freopen("10221.in","r",stdin);
freopen("10221.out","w",stdout);
#endif
while(scanf("%lf %lf %s",&s,&a,&unit)==3)
{
if(strcmp(unit,"min")==0) a=a/60;
if(a>180) a=360-a;
arc=(2.0*pi*(r+s))*(a/360.0);
chord=( (r+s)*sin(a/(180/pi)) )/sin( (0.5*(180-a))/(180/pi) );
printf("%.6lf %.6lf\n",arc,chord);
}
return 0;
}[/c]
minskcity
Experienced poster
Posts: 199
Joined: Tue May 14, 2002 10:23 am
Location: Vancouver

Post by minskcity »

Can anybody give the output for

Code: Select all

500 330 deg
Problem description is not very clear about what to output in such cases...
minskcity
Experienced poster
Posts: 199
Joined: Tue May 14, 2002 10:23 am
Location: Vancouver

Post by minskcity »

Can anybody give the output for

Code: Select all

500 330 deg
Problem description is not very clear about what to output in such cases...
Ghust_omega
Experienced poster
Posts: 115
Joined: Tue Apr 06, 2004 7:04 pm
Location: Venezuela

Post by Ghust_omega »

Hi minskcity, koola, b3yours3lf try this I/O, and for the people that have WA, this is from y AC Code:


[c]
Input :

500 30 deg
40 120 min
30 20 deg
70 27 min
100 90 deg
400 60 deg
100 60 min
500 60 min
500 300 deg
700 80 min
700 90 deg
9000 30 min
700 69 min
500 60 min
60 7 deg
500 330 deg <---
700 60 min
200 45 deg



ouput:

3633.775503 3592.408346
226.194671 226.183187
2258.456052 2247.007419
51.129420 51.129289
10273.007977 9248.956698
7162.831250 6840.000000
114.144533 114.143084
121.125850 121.124313
7267.551005 6940.000000
166.155345 166.151596
11215.485773 10097.484835
134.739418 134.738991
143.308985 143.306579
121.125850 121.124313
794.124810 793.631014
3633.775503 3592.408346
124.616509 124.614927
5215.043805 5082.035982

[/c]

Hope its helps
Keep posting :)
jaywinyeah
New poster
Posts: 19
Joined: Sun Aug 17, 2003 10:40 pm

Post by jaywinyeah »

Thanks for your help omega. Apparently, they want the smaller arc and chord length given an angle between satellites. They should have said so.
LL Cool Jay
The Formula Wizard
Jason Winokur
898989
Learning poster
Posts: 83
Joined: Wed Feb 01, 2006 12:59 pm
Location: (Fci-cu) Egypt
Contact:

10221 some problems in equations

Post by 898989 »

Salamo Aleko

I no the first formula for this problem of arc
But i do not know the second of cord
Can any one show it to me and give me a reference to know how i can derive them.
Thanks in advance
Sleep enough after death, it is the time to work.
Mostafa Saad
Zaspire
New poster
Posts: 36
Joined: Sun Apr 23, 2006 2:42 pm
Location: Russia

Post by Zaspire »

s*sin(a)/sin((PI-a)/2)
Don't forgot about a>PI
Post Reply

Return to “Volume 102 (10200-10299)”