Page 2 of 2

### THANKS

Posted: Mon Jun 26, 2006 9:13 pm
Sohel,
So kind of u.
THANK U SO MUCH. I get AC now .
take care n keep well, ok?

Posted: Wed Jun 20, 2007 1:57 am

Code: Select all

``````#include<iostream>
#include<cmath>
using namespace std;

int main()
{
double n,ang,area,r,r2,rim,areaspec,areaoffi,d1;
unsigned long long ar;
int count=0;

while(cin>>n>>area)
{
if(n<3)
break;

count++;

ang=((2*acos(0.0))/n);
r=sqrt((area/(n*cos(ang)*sin(ang))));

r2=r*cos(ang);

areaspec=((2*acos(0.0)*r*r)-area);
areaoffi=(area-(2*acos(0.0)*r2*r2));

ar=(unsigned long long)(areaspec*100000);
d1=(areaspec*100000)-ar;
if(d1>0.5 ||(d1==0.5 && (unsigned long long)ar%2!=0))
ar++;
cout<<(double)ar/100000<<" ";

ar=(unsigned long long)(areaoffi*100000);
d1=(areaoffi*100000)-ar;
if(d1>0.5 ||(d1==0.5 && (unsigned long long)ar%2!=0))
ar++;
cout<<(double)ar/100000<<"\n";

}
} ``````

Posted: Thu Jun 21, 2007 1:43 am
Forgot to print caseno?

### Re: 10451

Posted: Sat Apr 12, 2008 9:47 am
Someone please look at my code and tell me why i get WA....
i have tried a lot....

Code: Select all

``````// Ancient Village Sports 10451

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int ncase=0;
int n;
while(cin>>n)
{
ncase++;
long double area;
if(n<3) break;
cin>>area;
long double r = sqrt((2.0*area/(long double)n)/sin(4.0*acos(0.0)/(long double)n));
long double ri = r*cos(2.0*acos(0.0)/(long double)n);
r = (2.0*acos(0.0)*r*r) - area;
ri = area - (2.0*acos(0.0)*ri*ri);
r = 100000.0*r;
unsigned long long t = (unsigned long long)r;
if(((r-(long double)t)>0.5)||((r-(long double)t)==0.5 && t%2!=0))
t++;
r = (long double)t/100000.0;
ri = 100000.0*ri;
t = (unsigned long long)ri;
if(((ri-(long double)t)>0.5)||((ri-(long double)t)==0.5 && t%2!=0))
t++;
ri = (long double)t/100000.0;
cout<<"Case "<<ncase<<": "<<r<<" "<<ri<<endl;
}
return 0;
}

``````
Thanx a lot...

### Re: 10451 - Ancient Village Sports

Posted: Mon Sep 16, 2013 7:51 pm
This is a precision-error prone problem. I had to tweak a lot in my code to get Accepted.
Well, after a lot of WAs, I found out the precision of the judge for this problem.

1. Read and compute values as doubles
2. Print answer as a float
3. Don't use epsilons

There are many formulas for this problem, all of which work. However, you may get trapped in the precision error so heed this advice.

Just change

Code: Select all

``printf( "Case %d: %.5lf %.5lf\n", ++CASES, a, b );``
into

Code: Select all

``printf( "Case %d: %.5f %.5f\n", ++CASES, a, b );``

Code: Select all

``````cout.precision(5);
cout << fixed;
cout << "Case " << ++CASES << ": " << (float)a << " " << (float)b << endl;``````
Hope this helps

### Re: 10451 - Ancient Village Sports

Posted: Tue Aug 26, 2014 7:52 am
I don't know why i'm always getting a WA..

import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;

class Main
{
public static void main(String args[])throws Exception
{
Code Remove after getting AC in uva
}
}

### Re: 10451 - Ancient Village Sports

Posted: Tue Aug 26, 2014 5:39 pm

Code: Select all

``Scanner sc = new Scanner(System.in);``
Be careful with integer division. You must convert long to double. Change lines

Code: Select all

``````double Spectator = (2*PI*c)/(b*(Math.sin(Math.toRadians((double)360/b))));
``````
Or

Code: Select all

``````double Spectator = (2*PI*c)/(b*(Math.sin(Math.toRadians(360.0/b))));