Page 2 of 4

Posted: Tue Apr 01, 2003 8:16 am
by Dominik Michniewski
Do you consider a or b or c equal to 0 ?

Dominik

Posted: Wed Apr 02, 2003 4:32 pm
by Daredevil
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) ?

Posted: Wed Apr 02, 2003 4:47 pm
by kmhasan
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.

Posted: Mon Apr 07, 2003 8:03 am
by Daredevil
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 !!

Special cases

Posted: Sat Oct 04, 2003 2:40 am
by BiK
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

10195 WA why ????

Posted: Wed Dec 10, 2003 8:35 pm
by BarteQ
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]

10195 WA why ????

Posted: Wed Dec 10, 2003 8:36 pm
by BarteQ
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]

10195 WA Pliz Help...!!!

Posted: Tue May 25, 2004 8:49 am
by neno_uci
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:

Posted: Tue May 25, 2004 2:26 pm
by neno_uci
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(

10195 what is the problem with my code

Posted: Tue Jun 22, 2004 3:12 pm
by usman
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);
}
}
}
}

10195 - Must be something really obvious

Posted: Wed Jun 23, 2004 4:45 am
by mattapayne
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

Posted: Wed Jun 23, 2004 6:52 am
by sohel
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:

Posted: Wed Jun 23, 2004 7:07 am
by mattapayne
You are right. Got AC. Thanks.

Matt

Posted: Fri Jul 23, 2004 10:21 pm
by Sifu
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

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

Posted: Wed Jan 26, 2005 7:38 am
by J&Jewel
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.