Page 4 of 4
Posted: Tue Mar 06, 2007 10:57 pm
by Debashis Maitra
Post your code including header file
always try to compile your code in gcc / g++ compiler
anyway I think you haven't included math.h header file
that may help you
but...
Posted: Sun Mar 11, 2007 8:48 am
by starrynight
this time I include math.h header file...
but I got an WA?
Can anyone tell me why?
and..gcc &g++ is what?
thx!!
this is my code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
double a ,b ,c ,r ,s ,s2 ,area;
while (scanf("%lf %lf %lf",&a,&b,&c) != EOF)
{
s = ( a + b + c ) / 2.0;
area = sqrt(s * (s-a) * (s-b) * (s-c));
s2 = a + b + c;
r = 2.0 * area * (1.0 / s2);
printf("The radius of the round table is: %.3lf\n",r);
}
return 0;
}
Posted: Sun Mar 11, 2007 9:13 pm
by Debashis Maitra
what will be your output if a=0,b=0,c=0 or S= 0
it should be 0.000
GCC is the compiler for compiling C
and
G++ are the compiler for compiling C++ in Linux
I suggest you to use it because you can use large memory in it and UVA use linux
10195
Posted: Tue Mar 27, 2007 5:51 am
by mohidul18
#include<stdio.h>
#include<math.h>
void main(){
double a,b,c,r;
while(scanf("%lf %lf %lf",&a,&b,&c)){ r=(a+b+c)/2.0;
if(r)printf("The radius of the round table is: %.3lf\n",sqrt((r-a)*(r-b)*(r-c)/r));
else printf("The radius of the round table is: 0.000\n");}
}
Posted: Wed Mar 28, 2007 2:16 pm
by abdullah<cse du>
mohidul18,
there are some problems in your code. When your program terminates?
Change this line
Code: Select all
while(scanf("%lf %lf %lf",&a,&b,&c))
to
Code: Select all
while(scanf("%lf %lf %lf",&a,&b,&c)==3)
This is for end of file.
Another problem is if
a==0.0 || b==0.0 || c==0.0
Then redius is 0.000. Not for r.
I have changed this two and gets your code accepted.
ABDULLAH.
Re: 10195 - The Knights Of The Round Table
Posted: Sat Sep 06, 2008 12:53 pm
by sijal
try to use gcc and set compiler flags to -lm -lcrypt -O2 -pipe -ansi -DONLINE_JUDGE for c .
one time i have a compilation error and it was in comment lines .
Re: 10195 - The Knights Of The Round Table
Posted: Mon Sep 08, 2008 10:34 pm
by debugger
What is wrong with my code?
Code: Select all
#include<stdio.h>
#include<math.h>
int main(){
double a,b,c,s,r;
while((scanf("%lf %lf %lf",&a,&b,&c))==3){
if(a==0||b==0||c==0)
r=0.0000;
else{
s=(a+b+c)/2.0000;
r=sqrt((s-a)*(s-b)*(s-c)/s);
}
printf("The radious of the round table is: %.3lf\n",r);
}
return 0;
please somebody reply.
Re: 10195 - The Knights Of The Round Table
Posted: Sat Sep 13, 2008 12:27 pm
by sijal
radius is more correct than radious

Re: 10195 - The Knights Of The Round Table
Posted: Wed May 18, 2011 4:18 pm
by mdpallob
What is the wrong with this code?
Can anyone help me pls.............
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
double a,b,c;
while(cin>>a>>b>>c)
{
if(cin.eof())
break;
if(a!=0 && b!=0 && c!=0)
{
double x=(a+b+c)/2;
float r;
x=sqrt(((x-a)*(x-b)*(x-c))/x);
cout.precision(4);
cout<<"The radius of the round table is: "<<x<<"\n";
}
else
cout<<"The radius of the round table is: 0\n";
}
return 0;
}
Re: 10195 - The Knights Of The Round Table
Posted: Thu Jun 02, 2011 5:35 pm
by adnan_iut
Whenever you find the radius zero you should output 0.000 Not just 0
Re: 10195 - The Knights Of The Round Table
Posted: Fri Jun 03, 2011 5:46 am
by mdpallob
adnan_iut -------thank u for reply. but i still get wrong answer. here is the code with corrected 0.000
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
double a,b,c;
while(cin>>a>>b>>c)
{
if(cin.eof())
break;
if(a!=0 && b!=0 && c!=0)
{
double x=(a+b+c)/2;
float r;
x=sqrt(((x-a)*(x-b)*(x-c))/x);
cout.precision(4);
cout<<"The radius of the round table is: "<<x<<"\n";
}
else
cout<<"The radius of the round table is: 0.000\n";
}
return 0;
}
Re: 10195 - The Knights Of The Round Table
Posted: Sun Oct 02, 2011 8:47 am
by thnkndblv
It's some inputs and outputs...
Input:
0.0 0.0 0.0
1.0 1.0 1.0
1.0 1.0 0.0
1.0 0.0 1.0
0.0 1.0 1.0
3.1416 3.1416 3.1416
1000000.0 1000000.0 1000000.0
1000000.0 500000.0 500000.0
0.1 0.1 0.1
3 4 5
30 40 50
300 400 500
3000 4000 5000
30000 40000 50000
300000 400000 500000
Output:
The radius of the round table is: 0.000
The radius of the round table is: 0.289
The radius of the round table is: 0.000
The radius of the round table is: 0.000
The radius of the round table is: 0.000
The radius of the round table is: 0.907
The radius of the round table is: 288675.135
The radius of the round table is: 0.000
The radius of the round table is: 0.029
The radius of the round table is: 1.000
The radius of the round table is: 10.000
The radius of the round table is: 100.000
The radius of the round table is: 1000.000
The radius of the round table is: 10000.000
The radius of the round table is: 100000.000
Re: 10195 - The Knights Of The Round Table
Posted: Mon Feb 18, 2013 7:16 pm
by shuvokr
I am new in java...
why my java code got WA ....
Code ::
Code: Select all
import java.util.Scanner;
import java.math.BigInteger;
public class Main
{
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
double a, b, c, r;
int sk;
while(s.hasNext())
{
a = s.nextDouble();
b = s.nextDouble();
c = s.nextDouble();
if(a == 0 && b == 0 && c == 0)
System.out.println("The radius of the round table is: 0.000");
else
{
r = a + b + c;
r /= 2;
a = r - a;
b = r - b;
c = r - c;
a = a * b * c;
r = Math.sqrt(a / r);
r = r * 1000;
sk = (int)r;
r = (double)sk / 1000;
System.out.println("The radius of the round table is: "+r);
}
}
}
}
Re: 10195 - The Knights Of The Round Table
Posted: Thu Feb 21, 2013 12:59 am
by brianfry713
Try the I/O in the post before yours. You should always print 3 digits after the decimal point.
Re:
Posted: Sat Jul 26, 2014 1:06 am
by lighted
Stefan Pochmann wrote:And the special case is meaner (= even more unrealistic) than having one side length equal to zero. I hate these descriptions with a real life story behind them and then special cases that are so non-real-life. That's simply crap. My personal opinion. I don't like it when somebody purposely fools me.
<font size=-1>[ This Message was edited by: Stefan Pochmann on 2002-03-25 19:37 ]</font>
I agree with him.
