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

User avatar
Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:

Post by Debashis Maitra » Tue Mar 06, 2007 10:57 pm

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
Akash chhoyar swopno
Dream to touch the sky

starrynight
New poster
Posts: 7
Joined: Mon Mar 05, 2007 3:24 pm

but...

Post by starrynight » Sun Mar 11, 2007 8:48 am

this time I include math.h header file...
but I got an WA?
Can anyone tell me why?
and..gcc &g++ is what?
thx!! :D

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;
}

User avatar
Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:

Post by Debashis Maitra » Sun Mar 11, 2007 9:13 pm

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
Akash chhoyar swopno
Dream to touch the sky

mohidul18
New poster
Posts: 2
Joined: Sat Mar 10, 2007 4:21 pm
Location: Bogra,Bangladesh
Contact:

10195

Post by mohidul18 » Tue Mar 27, 2007 5:51 am

#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");}
}
i dun like them who likes me

abdullah<cse du>
New poster
Posts: 39
Joined: Mon Dec 04, 2006 2:18 pm
Location: Bangladesh(CSE DU)
Contact:

Post by abdullah<cse du> » Wed Mar 28, 2007 2:16 pm

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.

sijal
New poster
Posts: 9
Joined: Fri Jul 18, 2008 12:10 pm
Location: Iran-shiraz
Contact:

Re: 10195 - The Knights Of The Round Table

Post by sijal » Sat Sep 06, 2008 12:53 pm

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 .
Learn to swim.

debugger
New poster
Posts: 8
Joined: Tue Jul 29, 2008 6:24 pm

Re: 10195 - The Knights Of The Round Table

Post by debugger » Mon Sep 08, 2008 10:34 pm

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.

sijal
New poster
Posts: 9
Joined: Fri Jul 18, 2008 12:10 pm
Location: Iran-shiraz
Contact:

Re: 10195 - The Knights Of The Round Table

Post by sijal » Sat Sep 13, 2008 12:27 pm

radius is more correct than radious :)
Learn to swim.

mdpallob
New poster
Posts: 3
Joined: Wed May 18, 2011 4:11 pm

Re: 10195 - The Knights Of The Round Table

Post by mdpallob » Wed May 18, 2011 4:18 pm

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;
}

adnan_iut
New poster
Posts: 1
Joined: Thu May 19, 2011 8:44 am

Re: 10195 - The Knights Of The Round Table

Post by adnan_iut » Thu Jun 02, 2011 5:35 pm

Whenever you find the radius zero you should output 0.000 Not just 0

mdpallob
New poster
Posts: 3
Joined: Wed May 18, 2011 4:11 pm

Re: 10195 - The Knights Of The Round Table

Post by mdpallob » Fri Jun 03, 2011 5:46 am

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;
}

thnkndblv
New poster
Posts: 2
Joined: Sat Aug 13, 2011 11:26 pm

Re: 10195 - The Knights Of The Round Table

Post by thnkndblv » Sun Oct 02, 2011 8:47 am

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

shuvokr
Learning poster
Posts: 66
Joined: Tue Oct 02, 2012 8:16 pm
Location: Bangladesh

Re: 10195 - The Knights Of The Round Table

Post by shuvokr » Mon Feb 18, 2013 7:16 pm

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);
            }   
        }
    }
}

Code: Select all

enjoying life ..... 

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10195 - The Knights Of The Round Table

Post by brianfry713 » Thu Feb 21, 2013 12:59 am

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!

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re:

Post by lighted » Sat Jul 26, 2014 1:06 am

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. :evil:
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Post Reply

Return to “Volume 101 (10100-10199)”

Who is online

Users browsing this forum: No registered users and 1 guest