## 10221 - Satellites

Moderator: Board moderators

898989
Learning poster
Posts: 83
Joined: Wed Feb 01, 2006 12:59 pm
Location: (Fci-cu) Egypt
Contact:
Please can you give me some trick test cases
Sleep enough after death, it is the time to work.

serendipity
New poster
Posts: 6
Joined: Tue May 09, 2006 9:22 pm

### 10221 Still WA!!!!!!!!!!!Plz help!

can someone tell why am i getting WA?
I have checked all the test cases provided by the Electronic board. I cannot uderstand also wot wud b the calculation for a=180;

#include<stdio.h>
#include<math.h>
#include<string.h>

#define MAX 5
//#define pi 3.14159265358979323846
#define R 6440

int main(void)
{

double s,a ;
char str[MAX];

//freopen("10221.txt","r",stdin);
pi= acos(-1);
while((scanf("%lf%lf%s",&s,&a,str))==3)
{

if(a>180 && !( strcmp(str,"deg")) )
{
a=360-a;
}

if(!(strcmp(str,"deg")))
{

}
else
{
a=a/60;

}

/*if(a==180) ///is it ok?????????
{
cord= 2.0*R+s;

}*/

if (a<=180)
{

cord=( (R+s)*sin(a/(180/pi)) )/sin((0.5*(180-a))/(180/pi) );

}

printf("%.6lf %.6lf\n",arc, cord);
}

return 0;
}

sakhassan
Experienced poster
Posts: 105
Joined: Sat Mar 11, 2006 9:42 am
Location: cse,DU
....
U should consider a = 180 & when a != 180..
By the way the formula for chord is
for when a != 180
and Chord_distance=2*radius for when a = 180
am thinking r u calculation ur radius as

newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Contact:

### Re: 10221 - Satellites

All test case has passed but still WA!
where is the problem?

Code: Select all

``````#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define R 6440
#define PI 2*acos(0.0)

using namespace std;

int main(){
//freopen("in.txt","rt",stdin);
int s,a;
double arcDistance,cordDistance,sinA,sinB;
char str[100];
while(gets(str))
{
sscanf(str,"%d %d %s",&s,&a,str);
if(strstr(str,"min"))
a /= 60;
s = s + R;
arcDistance = s * a * PI/180;
sinA = sin(a*PI/180);
sinB = sin((180 - a)*PI/360);
if(a != 180)
cordDistance = s * sinA / sinB;
else
cordDistance = 2*s;
printf("%.6lf %.6lf\n",fabs(arcDistance),fabs(cordDistance));
}
return 0;
}
``````

debugger
New poster
Posts: 8
Joined: Tue Jul 29, 2008 6:24 pm

### Re: 10221 - Satellites

Please say, what is my wrong? i am so suppressed.

Code: Select all

``````#include<stdio.h>
#include<math.h>

int main(){
char ch[6];
pi=2*acos(0.0);
while((scanf("%lf %lf %s",&s, &a, &ch))==3){
if(ch[0]=='m')
a=a/60;
if(a>180)
a=a-180;

if(a==180){
arc=pi*(s+6440);
chord=2*(s+6440);
}
else{
}
printf("%.6lf %.6lf\n",arc,chord);
}
return 0;
}
``````

calicratis19
Learning poster
Posts: 76
Joined: Mon Jul 21, 2008 8:50 am
Contact:

### wa pls help

deleted after ac
Last edited by calicratis19 on Tue Feb 10, 2009 4:06 pm, edited 1 time in total.
Heal The World

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 10221 - Satellites

reduce calculation.....

Code: Select all

``accepted``
Last edited by Obaida on Tue Aug 11, 2009 8:33 pm, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

calicratis19
Learning poster
Posts: 76
Joined: Mon Jul 21, 2008 8:50 am
Contact:

### Re: 10221 - Satellites

i got wa in this problem for a long time. it was nothing but precision err.i just decreased calculation in the code .i printed them directly nd then AC . meaning i did not use variable like arc , cord ,red etc.i did those operation in printf .... hope u understand. nd i didnt understand ur method .i used different method nd it takes less calculation then urs.
Heal The World

asif_khan_ak_07
New poster
Posts: 25
Joined: Fri Apr 17, 2009 8:24 am

### Re: 10221 - Satellites

Code: Select all

``````#include<stdio.h>
#include<math.h>
#include<string.h>

#define pi 3.1415926535897932384626433832795

int main()
{

//freopen("10221.txt","r",stdin);
int s;
char a[10];
long double ans,temp,len,ac,deg;
while((scanf("%d %Lf %s",&s,&deg,&a)==3)){

if(!strcmp(a,"min"))
ans=deg/60;
else
ans=deg;
if(ans>180)
ans-360-ans;
ans=(pi*ans)/180;
ac=6440+s;
temp=(ac)*ans;
len=2*ac*ac*cos(ans);
len=(ac*ac)+(ac*ac)-len;
len=sqrt(len);
printf("%.6Lf %.6Lf\n",temp,len);

}

return 0;
}``````

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 10221 - Satellites

@calicratis19 thank you very much. at last worked by reducing calculation.
More variable although with right calculation surly will get wrong answer.
@asif_khan_ak_07 try to reduce your variables. and don't forget to edit this part.

Code: Select all

``ans-360-ans;``
try_try_try_try_&&&_try@try.com
This may be the address of success.

fkrafi
New poster
Posts: 13
Joined: Wed Sep 15, 2010 1:36 pm

### Re: 10221 - Satellites

Why WA?????

Code: Select all

``````Solved
``````

plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

### Re: 10221 - Satellites

Remember, if the angle is greater than 180.0(in degrees), then calculate with 360 - angle size . Just do the following thing to avoid complexity, take s and a as double and the angle unit as string(Remember to eliminate buffer). Then if str[0] == 'm', angle(a) = a / 60.0. I got AC without adding 1e-8 or stuff like that. Good luck
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

sumit saha shawon
New poster
Posts: 19
Joined: Tue Jun 26, 2012 9:19 pm

### Re: 10221 - Satellites

I am getting run time error.But I think my code is ok.
My code:

#include<stdio.h>
#include<math.h>
#define pi 2*acos(0)
int main()
{
// double pi=;

char array[5];
while(scanf("%lf%lf%S",&s,&angel,&array)==3)
{
if(angel>180)
angel=360-angel;
//printf("%d\n",angel);
if(array[0]=='m')
angel=angel/60;

printf("%0.6lf %0.6lf\n",ans1,ans2);
}
return 0;
}

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

### Re: 10221 - Satellites

Change line 10 to:
while(scanf("%lf%lf%s",&s,&angel,array)==3)
Check input and AC output for thousands of problems on uDebug!

sumit saha shawon
New poster
Posts: 19
Joined: Tue Jun 26, 2012 9:19 pm

### Re: 10221 - Satellites

thanks I have got Ac