10221 - Satellites
Moderator: Board moderators
-
- 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];
double rad, arc, cord, pi;
//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")))
{
rad=(pi*a)/180;
}
else
{
a=a/60;
rad=(pi*a)/180;
}
/*if(a==180) ///is it ok?????????
{
arc=(R+s)*rad;
cord= 2.0*R+s;
}*/
if (a<=180)
{
arc = (R+s)*rad;
cord=( (R+s)*sin(a/(180/pi)) )/sin((0.5*(180-a))/(180/pi) );
}
printf("%.6lf %.6lf\n",arc, cord);
}
return 0;
}
thanx in advance!
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];
double rad, arc, cord, pi;
//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")))
{
rad=(pi*a)/180;
}
else
{
a=a/60;
rad=(pi*a)/180;
}
/*if(a==180) ///is it ok?????????
{
arc=(R+s)*rad;
cord= 2.0*R+s;
}*/
if (a<=180)
{
arc = (R+s)*rad;
cord=( (R+s)*sin(a/(180/pi)) )/sin((0.5*(180-a))/(180/pi) );
}
printf("%.6lf %.6lf\n",arc, cord);
}
return 0;
}
thanx in advance!
well u had made an silly mistake
....
U should consider a = 180 & when a != 180..
By the way the formula for chord is
Chord_distance=2*radius*sin(angle/2)
for when a != 180
and Chord_distance=2*radius for when a = 180
am thinking r u calculation ur radius as
radius = R or radius = R+s -----> ur mistake
....
U should consider a = 180 & when a != 180..
By the way the formula for chord is
Chord_distance=2*radius*sin(angle/2)
for when a != 180
and Chord_distance=2*radius for when a = 180
am thinking r u calculation ur radius as
radius = R or radius = R+s -----> ur mistake
-
- Experienced poster
- Posts: 162
- Joined: Thu Jul 13, 2006 7:07 am
- Location: Campus Area. Dhaka.Bangladesh
- Contact:
Re: 10221 - Satellites
All test case has passed but still WA!
where is the problem?
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;
}
http://www.newton.0fees.net is enough!
Re: 10221 - Satellites
Please say, what is my wrong? i am so suppressed.
Quickly. please.
Code: Select all
#include<stdio.h>
#include<math.h>
int main(){
double s,a,pi,chord,rad,arc;
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;
rad=pi*a/180;
if(a==180){
arc=pi*(s+6440);
chord=2*(s+6440);
}
else{
chord=2*(s+6440)*sin(rad/2);
arc=rad*(s+6440);
}
printf("%.6lf %.6lf\n",arc,chord);
}
return 0;
}
-
- Learning poster
- Posts: 76
- Joined: Mon Jul 21, 2008 8:50 am
- Location: SUST,SYLHET,BANGLADESH.
- 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
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.
This may be the address of success.
-
- Learning poster
- Posts: 76
- Joined: Mon Jul 21, 2008 8:50 am
- Location: SUST,SYLHET,BANGLADESH.
- 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
-
- New poster
- Posts: 25
- Joined: Fri Apr 17, 2009 8:24 am
Re: 10221 - Satellites
why wrong answer
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,°,&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;
}
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.
more info in my pm. keep solving
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.
This may be the address of success.
Re: 10221 - Satellites
Why WA?????
Code: Select all
Solved
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
-
- 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=;
double s,angel,rad,radius,ans1,ans2;
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;
rad=(pi/180)*angel;
//printf("%lf\n",rad);
radius=s+6440;
ans1=rad*radius;
ans2=2*radius*sin(rad/2.0);
printf("%0.6lf %0.6lf\n",ans1,ans2);
}
return 0;
}
My code:
#include<stdio.h>
#include<math.h>
#define pi 2*acos(0)
int main()
{
// double pi=;
double s,angel,rad,radius,ans1,ans2;
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;
rad=(pi/180)*angel;
//printf("%lf\n",rad);
radius=s+6440;
ans1=rad*radius;
ans2=2*radius*sin(rad/2.0);
printf("%0.6lf %0.6lf\n",ans1,ans2);
}
return 0;
}
-
- 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)
while(scanf("%lf%lf%s",&s,&angel,array)==3)
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 19
- Joined: Tue Jun 26, 2012 9:19 pm
Re: 10221 - Satellites
thanks I have got Ac