10221 - Satellites

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

Moderator: Board moderators

10221 - Satellites

Postby htl » Wed Jul 10, 2002 6:47 am

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]
htl
Experienced poster
 
Posts: 185
Joined: Fri Jun 28, 2002 12:05 pm
Location: Taipei, Taiwan

Postby Picard » Wed Jul 10, 2002 1:43 pm

it's a bit tricky. for example: what is the arc distance for 240 degrees?
Picard
Learning poster
 
Posts: 96
Joined: Mon Jun 24, 2002 1:22 pm
Location: Hungary

Postby htl » Wed Jul 10, 2002 5:21 pm

Yep, I found that if a>180 my code will give the wrong answer. I've got it AC.
htl
Experienced poster
 
Posts: 185
Joined: Fri Jun 28, 2002 12:05 pm
Location: Taipei, Taiwan

10227 WA

Postby Terrible » Tue Aug 20, 2002 4:43 am

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

Should anyone replay me? Thanks
Terrible
New poster
 
Posts: 2
Joined: Mon Aug 19, 2002 8:27 am

10221 a easy problem,but why wrong answer?

Postby koola » Sun Nov 03, 2002 4:06 am


#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);
}
}
koola
New poster
 
Posts: 2
Joined: Wed Sep 25, 2002 10:41 am

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

Postby uzioriluzan » Tue Nov 05, 2002 4:21 pm

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);
}
}
uzioriluzan
New poster
 
Posts: 27
Joined: Thu Feb 14, 2002 2:00 am

10221 - Satelites

Postby Culter » Mon Jul 28, 2003 5:00 pm

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;
}
Culter
New poster
 
Posts: 2
Joined: Mon Jul 28, 2003 3:21 pm
Location: Zagreb

Postby Per » Tue Jul 29, 2003 7:33 am

Think about angle > pi. You have a mistake there.
Per
A great helper
 
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Postby b3yours3lf » Wed Aug 13, 2003 11:06 am

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]
b3yours3lf
New poster
 
Posts: 44
Joined: Wed Aug 14, 2002 3:02 am

Postby minskcity » Fri Aug 13, 2004 6:01 am

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

Postby minskcity » Fri Aug 13, 2004 6:04 am

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

Postby Ghust_omega » Sat Sep 04, 2004 10:45 am

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 :)
User avatar
Ghust_omega
Experienced poster
 
Posts: 115
Joined: Tue Apr 06, 2004 7:04 pm
Location: Venezuela

Postby jaywinyeah » Mon Sep 06, 2004 6:54 am

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
jaywinyeah
New poster
 
Posts: 13
Joined: Sun Aug 17, 2003 10:40 pm

10221 some problems in equations

Postby 898989 » Mon Jun 26, 2006 8:22 pm

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
898989
Learning poster
 
Posts: 83
Joined: Wed Feb 01, 2006 12:59 pm
Location: (Fci-cu) Egypt

Postby Zaspire » Thu Jul 13, 2006 10:55 am

s*sin(a)/sin((PI-a)/2)
Don't forgot about a>PI
User avatar
Zaspire
New poster
 
Posts: 36
Joined: Sun Apr 23, 2006 2:42 pm
Location: Russia

Next

Return to Volume CII

Who is online

Users browsing this forum: Bing [Bot] and 1 guest