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

898989
Learning poster
Posts: 83
Joined: Wed Feb 01, 2006 12:59 pm
Location: (Fci-cu) Egypt
Contact:

Post by 898989 »

Please can you give me some trick test cases
Sleep enough after death, it is the time to work.
Mostafa Saad
serendipity
New poster
Posts: 6
Joined: Tue May 09, 2006 9:22 pm

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

Post by serendipity »

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!
sakhassan
Experienced poster
Posts: 105
Joined: Sat Mar 11, 2006 9:42 am
Location: cse,DU

Post by sakhassan »

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
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Re: 10221 - Satellites

Post by newton »

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

Post by debugger »

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

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;
    }
Quickly. please. :cry: :cry: :cry: :cry:
calicratis19
Learning poster
Posts: 76
Joined: Mon Jul 21, 2008 8:50 am
Location: SUST,SYLHET,BANGLADESH.
Contact:

wa pls help

Post by calicratis19 »

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
Location: (BUBT) Dhaka,Bagladesh.

Re: 10221 - Satellites

Post by Obaida »

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
Location: SUST,SYLHET,BANGLADESH.
Contact:

Re: 10221 - Satellites

Post by calicratis19 »

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 :D . 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 :oops: :oops: :oops: .i used different method nd it takes less calculation then urs. :wink: :wink:
Heal The World
asif_khan_ak_07
New poster
Posts: 25
Joined: Fri Apr 17, 2009 8:24 am

Re: 10221 - Satellites

Post by asif_khan_ak_07 »

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,&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
Location: (BUBT) Dhaka,Bagladesh.

Re: 10221 - Satellites

Post by Obaida »

@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;
more info in my pm. keep solving :D
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

Post by fkrafi »

Why WA?????

Code: Select all

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

Re: 10221 - Satellites

Post by plamplam »

Remember, if the angle is greater than 180.0(in degrees), then calculate with 360 - angle size :D. 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

Post by sumit saha shawon »

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;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10221 - Satellites

Post by brianfry713 »

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

Post by sumit saha shawon »

thanks I have got Ac
Post Reply

Return to “Volume 102 (10200-10299)”