10195 - The Knights Of The Round Table
Moderator: Board moderators
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
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.
K M Hasan
http://www.cs.umanitoba.ca/~kmhasan/
http://www.cs.umanitoba.ca/~kmhasan/
Special cases
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
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
10195 WA why ????
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]
#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]
10195 WA why ????
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]
#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]
10195 WA Pliz Help...!!!
Hello, I 've tried to solve P10195 several times, but it gives WA, 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:
[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

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

10195 what is the problem with my code
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);
}
}
}
}
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);
}
}
}
}
-
- New poster
- Posts: 8
- Joined: Thu Jun 17, 2004 5:50 am
10195 - Must be something really obvious
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
[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
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...
.. but you seemed to return from the main function when any of the three
inputs is zero.
And this line is irrelevant..
[c]
if(a>0 && a<=1000000 && b >0 && b<=1000000 && c>0 &&c<=1000000)
[/c]
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.

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

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

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

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.

-
- New poster
- Posts: 8
- Joined: Thu Jun 17, 2004 5:50 am
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);
}
}
}
Try this and see whether it works....... Take care and best of luck 
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);
}
}
}


-
- 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......
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.
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!