10195 - The Knights Of The Round Table

All about problems in Volume 101. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Dominik Michniewski
Guru
Posts: 832
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Tue Apr 01, 2003 8:16 am

Do you consider a or b or c equal to 0 ?

Dominik
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

Daredevil
New poster
Posts: 19
Joined: Tue Apr 01, 2003 7:47 am
Location: Earth

Post by Daredevil » Wed Apr 02, 2003 4:32 pm

You mean one of them (a,b,c) or both ((a,b),(b,c),(a,c)) or the three of them are zeroes?
And what if these zeroes occur? should I ignore this input (since it can produce negative result in the sqrt which is undefined) ?

User avatar
kmhasan
Problemsetter
Posts: 107
Joined: Fri Oct 26, 2001 2:00 am
Location: Canada
Contact:

Post by kmhasan » Wed Apr 02, 2003 4:47 pm

If a=0 OR b=0 OR c=0 (any of them is zero, all of them are zero, anything) the output would be zero.

Daredevil
New poster
Posts: 19
Joined: Tue Apr 01, 2003 7:47 am
Location: Earth

Post by Daredevil » Mon Apr 07, 2003 8:03 am

Got AC now!!!!
But when either of the side is 0, would that be a triangle? It should be a line instead of a triangle!!
But THANK YOU VERY MUCH !!!!!
Have a nice life !!

BiK
Experienced poster
Posts: 104
Joined: Tue Sep 23, 2003 5:49 pm

Special cases

Post by BiK » Sat Oct 04, 2003 2:40 am

Actually, the special case with only one of a, b and c equal to zero is only possible for the non-zero lengths being equal. (Because of the condition max{a,b,c}<=(a+b+c)/2). In this case the radius is zero by the used and already discussed Heron-formule.
Actually, the really bad case is the case a=b=0, c>0! Then sqrt(something<0) is not defined!!!

Am I right?

Stefan for the BiK Team

BarteQ
New poster
Posts: 2
Joined: Mon Nov 24, 2003 10:39 pm
Location: POLAND

10195 WA why ????

Post by BarteQ » Wed Dec 10, 2003 8:35 pm

My code in C++ is:

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

int main()
{ double a,b,c;
double S;
double p;
while(scanf("%lf %lf %lf", &a, &b, &c)==3)
{
if(a!=0 && b!=0 && c!=0)
{
p = (a+b+c)/2;
S=sqrt((p-a)*(p-b)*(p-c)/p);
printf("The radius of the round table is: %.3lf\n",S);
}
else
printf("The radius of the round table is: 0\n");

}
return 0;
}

and I still get WA. Why ?

Thx for any response[cpp][/cpp]

BarteQ
New poster
Posts: 2
Joined: Mon Nov 24, 2003 10:39 pm
Location: POLAND

10195 WA why ????

Post by BarteQ » Wed Dec 10, 2003 8:36 pm

My code in C++ is:

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

int main()
{ double a,b,c;
double S;
double p;
while(scanf("%lf %lf %lf", &a, &b, &c)==3)
{
if(a!=0 && b!=0 && c!=0)
{
p = (a+b+c)/2;
S=sqrt((p-a)*(p-b)*(p-c)/p);
printf("The radius of the round table is: %.3lf\n",S);
}
else
printf("The radius of the round table is: 0\n");

}
return 0;
}

and I still get WA. Why ?

Thx for any response[cpp][/cpp]

neno_uci
Experienced poster
Posts: 104
Joined: Sat Jan 17, 2004 12:26 pm
Location: Cuba

10195 WA Pliz Help...!!!

Post by neno_uci » Tue May 25, 2004 8:49 am

Hello, I 've tried to solve P10195 several times, but it gives WA, what is wrong with my code? :evil:

I have also checked the case that a == 0 or b == 0 or c == 0, here is my code:

[cpp]
#include <stdio.h>
#include <math.h>

int main()
{
double a, b, c, s;

while (scanf("%lf %lf %lf", &a, &b, &c) != EOF) {

if (a != 0 && b != 0 && c != 0) {

s = (a + b + c) / 2;
s = sqrt((s-a)*(s-b)*(s-c)/s);
printf("The radius of the round table is: %0.3lf\n", s);
}
else
printf("The radius of the round table is: 0\n");
}

return 0;
}
[/cpp]

I am frustrated :cry:

neno_uci
Experienced poster
Posts: 104
Joined: Sat Jan 17, 2004 12:26 pm
Location: Cuba

Post by neno_uci » Tue May 25, 2004 2:26 pm

I just made some changes in my code, now got AC :P ...!!!
WA was given due to precission errors, I think...

However you may find this lines very useful:

while (scanf(

usman
New poster
Posts: 1
Joined: Mon Jun 21, 2004 11:46 pm

10195 what is the problem with my code

Post by usman » Tue Jun 22, 2004 3:12 pm

Hello, I 've tried to solve 10195 several times, but it gives wrong answer, what is wrong with my code?

I have also checked the case that a == 0 or b == 0 or c == 0, here is my code, and also check that the side are of made triangle or not i uses law of cos , i also check the limits of input

C++:
[/cpp]
#include<stdio.h>
#include<math.h>

double a,b,c,s,alpha,beta,gama;

void main(){

while(scanf("%lf %lf %lf",&a,&b,&c)!=EOF)
{
if(a>=1 && a<=1000000 && b >=1 && b<=1000000 && c>=1 &&c<=1000000)
{
beta = (double) acos(((c*c)+(a*a)-(b*b))/(2*a*c));
alpha = (double) acos(((b*b)+(c*c)-(a*a))/(2*b*c));
gama = (double) acos(((a*a)+(b*b)-(c*c))/(2*a*b));
if(beta+alpha+gama==180.00 || beta+alpha+gama >=179.60 ||beta+alpha+gama <=180.00 )
{
s=(a+b+c)/2;a=sqrt((s-a)*(s-b)*(s-c)/s);
printf("The radius of the round table is: %.3lf\n",a);
}
}
}
}

mattapayne
New poster
Posts: 8
Joined: Thu Jun 17, 2004 5:50 am

10195 - Must be something really obvious

Post by mattapayne » Wed Jun 23, 2004 4:45 am

What am I missing here?:
[C++]

#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
double a,b,c, radius, peri;
while(cin >> a >> b >> c)
{
if(a>0 && a<=1000000 && b >0 && b<=1000000 && c>0 &&c<=1000000)
{
peri = (a + b + c) / 2;
radius = sqrt((peri - a) * (peri - b) * (peri - c) / peri);
cout << setiosflags(ios::fixed) << setprecision(3) << "The radius of the round table is: " << radius << "\n";
}
else
exit(1);
}
return 0;
}

Thanks,
Matt

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel » Wed Jun 23, 2004 6:52 am

To mattapayne :

The values of a b or c can be zero...
and if either of them is zero then the answer is also zero... :wink:

.. but you seemed to return from the main function when any of the three
inputs is zero. :o

And this line is irrelevant..
[c]
if(a>0 && a<=1000000 && b >0 && b<=1000000 && c>0 &&c<=1000000)
[/c] :roll:

Since the problemset says No triangle size will be greater than 1000000 , you can safely assume they won't give you numbers more than this limit.

I have changed this two parts of your code and got AC.
Hope it helps.
:wink:

mattapayne
New poster
Posts: 8
Joined: Thu Jun 17, 2004 5:50 am

Post by mattapayne » Wed Jun 23, 2004 7:07 am

You are right. Got AC. Thanks.

Matt

Sifu
New poster
Posts: 1
Joined: Fri Jul 23, 2004 10:07 pm

Post by Sifu » Fri Jul 23, 2004 10:21 pm

I think you were on the right track but made some unnecessary checking.....
It should be something like this
[/cpp]
//10195
// knights of the round table

#include <stdio.h>
#include <iostream.h>
#include <math.h>
void main()
{
double a,b,c,s,r;
while (cin>>a>>b>>c)
{

if(a==0.0||b==0.0||c==0.0)
printf("The radius of the round table is: 0.000\n");
else
{
s=(a+b+c)/2;
if(s<0)
s = s* -1;

r=(s-a)*(s-b)*(s-c)/s;
r=sqrt(r);
printf("The radius of the round table is: %.3lf\n", r);
}
}

}

:lol: Try this and see whether it works....... Take care and best of luck :P

User avatar
J&Jewel
New poster
Posts: 50
Joined: Thu Jul 31, 2003 10:43 am
Location: Daffodil University,Dhaka,Bangladesh
Contact:

10195(Knight round table)..Pleaseeeeee any one......

Post by J&Jewel » Wed Jan 26, 2005 7:38 am

is not the right process...?
perimeter, s=(a+b+c)/2;
the radius of the cicle, r=sqrt(s*(s-a)*(s-b)*(s-c))/s;

all are in double.
I hate Wrong Answer!

Post Reply

Return to “Volume 101 (10100-10199)”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest