Page 1 of 3
10221 - Satellites
Posted: Wed Jul 10, 2002 6:47 am
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]
Posted: Wed Jul 10, 2002 1:43 pm
by Picard
it's a bit tricky. for example: what is the arc distance for 240 degrees?
Posted: Wed Jul 10, 2002 5:21 pm
by htl
Yep, I found that if a>180 my code will give the wrong answer. I've got it AC.
10227 WA
Posted: Tue Aug 20, 2002 4:43 am
by Terrible
Should anyone have some sample inputs and output..
Should I consider the angle greater than 360....
Should anyone replay me? Thanks
10221 a easy problem,but why wrong answer?
Posted: Sun Nov 03, 2002 4:06 am
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);
}
}
Re: 10221 a easy problem,but why wrong answer?
Posted: Tue Nov 05, 2002 4:21 pm
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);
}
}
10221 - Satelites
Posted: Mon Jul 28, 2003 5:00 pm
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;
}
Posted: Tue Jul 29, 2003 7:33 am
by Per
Think about angle > pi. You have a mistake there.
Posted: Wed Aug 13, 2003 11:06 am
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]
Posted: Fri Aug 13, 2004 6:01 am
by minskcity
Can anybody give the output for
Problem description is not very clear about what to output in such cases...
Posted: Fri Aug 13, 2004 6:04 am
by minskcity
Can anybody give the output for
Problem description is not very clear about what to output in such cases...
Posted: Sat Sep 04, 2004 10:45 am
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

Posted: Mon Sep 06, 2004 6:54 am
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.
10221 some problems in equations
Posted: Mon Jun 26, 2006 8:22 pm
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
Posted: Thu Jul 13, 2006 10:55 am
by Zaspire
s*sin(a)/sin((PI-a)/2)
Don't forgot about a>PI