10210 - Romeo and Juliet !

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

Post Reply
skinnyguy
New poster
Posts: 17
Joined: Fri Oct 22, 2004 3:41 pm

10210 - Romeo and Juliet !

Post by skinnyguy » Sat Oct 23, 2004 12:09 pm

Can someone please give me sample inputs so i can try to figure out where the problem lies. my program works for the 2 sample inputs provided, but i dont know how to figure out if it is correct.
Thanks.

User avatar
Rocky
Experienced poster
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am
Contact:

i give some input & output of 10210 try now.

Post by Rocky » Thu Oct 28, 2004 7:01 am

input:
25 25 30 30 50 55
54 80 82 45 60 70
20 30 45 67 65 79
100 200 30 400 45 50
90 80 70 100 56 89

output :
code:
10.885
42.192
29.503
389.698
19.572

skinnyguy
New poster
Posts: 17
Joined: Fri Oct 22, 2004 3:41 pm

Post by skinnyguy » Thu Oct 28, 2004 2:24 pm

thanks for the inputs
my code gives correct responses for these inputs too...
but the online judge says wrong answers again an again
i am quite a newbie and am sometimes confused how to handle inputs and outputs for these problems.
plz tell me what's wrong with it

Code: Select all

[cpp]
#include<stdio.h>
#include<math.h>
#define PI 3.1415926
float toRad(float);
float absolute(float);
int main(/*int,char***/)
{
	float x1,y1,x2,y2,ang_CMD,ang_ENF,x,m;
	while(scanf("%f %f %f %f %f %f\n",&x1,&y1,&x2,&y2,&ang_CMD,&ang_ENF)>0)
	{
		x=sqrt(pow(absolute(x1-x2),2)+pow(absolute(y1-y2),2));
		m=((1.0/tan(toRad(ang_CMD)))+(1.0/tan(toRad(ang_ENF))))*x;
		printf("%.3f\n",m);
	}
	return 0;
}
float toRad(float a)
{
	return ((a/180.000000)*PI);
}
float absolute(float x)
{
    if(x<0)return (-x);
    return x;
}
[/cpp]
i wonder if the formula is correct(i assure u i am pretty good at math though, no bragging really).
i will be greatful...

User avatar
Rocky
Experienced poster
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am
Contact:

Post by Rocky » Sat Oct 30, 2004 9:27 am

Well I Found Some Worng In you'r code.you make it complex but you can do it easily By the way i thing its wrong for POW FUNCTION & absoulet function.MULTIPLY (x1-x2)*(x1-x2) in this way you dont need to call absolulet function or pow.And DEFINE PI=2*acos(0.0) & use double data type.Thus your code become simple. BY.

B.D:if you want to see my code reply again i send it.

skinnyguy
New poster
Posts: 17
Joined: Fri Oct 22, 2004 3:41 pm

Post by skinnyguy » Sat Oct 30, 2004 6:37 pm

thanks a lot for the help...
i got accepted now.
i guess the problem indeed was fixed just by substituting the value of PI...
perhaps something to do with portability of code and difference in gcc/borland(i use borland though).
Thanks a lot again :D

User avatar
Rocky
Experienced poster
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am
Contact:

Post by Rocky » Sun Oct 31, 2004 6:40 am

Well done for get accepted.BY

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

Re: 10210 - Romeo & Juliet !

Post by debugger » Fri Sep 05, 2008 12:36 pm

Please say why i amng wrong answer? My code below.please.

Code: Select all


code removed after accepted
please some body reply.

DD
Experienced poster
Posts: 145
Joined: Thu Aug 14, 2003 8:42 am
Location: Mountain View, California
Contact:

Re: 10210 - Romeo & Juliet !

Post by DD » Thu Apr 07, 2011 11:52 pm

Originally, I thought that there may be some EPS problems. However, after I submitted and got A.C., I found this problem is really generous on precision :P
Have you ever...
  • Wanted to work at best companies?
  • Struggled with interview problems that could be solved in 15 minutes?
  • Wished you could study real-world problems?
If so, you need to read Elements of Programming Interviews.

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

Re: 10210 - Romeo & Juliet !

Post by brianfry713 » Tue Dec 03, 2013 3:04 am

That is AC code
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 102 (10200-10299)”