10195 - The Knights Of The Round Table
Moderator: Board moderators
- Debashis Maitra
- Learning poster
- Posts: 62
- Joined: Sun Jul 09, 2006 8:31 am
- Location: University of Dhaka
- Contact:
-
- New poster
- Posts: 7
- Joined: Mon Mar 05, 2007 3:24 pm
but...
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;
}
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;
}
- Debashis Maitra
- Learning poster
- Posts: 62
- Joined: Sun Jul 09, 2006 8:31 am
- Location: University of Dhaka
- Contact:
10195
#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");}
}
#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");}
}
i dun like them who likes me
-
- New poster
- Posts: 39
- Joined: Mon Dec 04, 2006 2:18 pm
- Location: Bangladesh(CSE DU)
- Contact:
mohidul18,
there are some problems in your code. When your program terminates?
Change this line
to
This is for end of file.
Another problem is if
I have changed this two and gets your code accepted.
ABDULLAH.
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))
Code: Select all
while(scanf("%lf %lf %lf",&a,&b,&c)==3)
Another problem is if
Then redius is 0.000. Not for r.a==0.0 || b==0.0 || c==0.0
I have changed this two and gets your code accepted.
ABDULLAH.
Re: 10195 - The Knights Of The Round Table
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 .
one time i have a compilation error and it was in comment lines .
Learn to swim.
Re: 10195 - The Knights Of The Round Table
What is wrong with my code?
please somebody reply.
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;
Re: 10195 - The Knights Of The Round Table
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;
}
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
Whenever you find the radius zero you should output 0.000 Not just 0
Re: 10195 - The Knights Of The Round Table
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;
}
#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
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
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
I am new in java...
why my java code got WA ....
Code ::
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);
}
}
}
}
Code: Select all
enjoying life .....
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10195 - The Knights Of The Round Table
Try the I/O in the post before yours. You should always print 3 digits after the decimal point.
Check input and AC output for thousands of problems on uDebug!
Re:
I agree with him.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>

A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman