## 10451 - Ancient Village Sports

Moderator: Board moderators

deena sultana
New poster
Posts: 36
Joined: Mon Jun 19, 2006 5:43 pm
Contact:

### THANKS

Sohel,
So kind of u.
THANK U SO MUCH. I get AC now .
take care n keep well, ok?

ankit.arora
New poster
Posts: 11
Joined: Tue May 22, 2007 10:09 pm
Location: India

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

}
} ``````

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
Forgot to print caseno?
Ami ekhono shopno dekhi...
HomePage

abhineet.bansal
New poster
Posts: 2
Joined: Fri Jul 20, 2007 3:07 pm

### Re: 10451

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...

Hikari9
New poster
Posts: 20
Joined: Tue Jan 22, 2013 4:39 pm

### Re: 10451 - Ancient Village Sports

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

AbyssalGreed
New poster
Posts: 9
Joined: Mon Aug 25, 2014 5:25 am

### Re: 10451 - Ancient Village Sports

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
}
}
Last edited by AbyssalGreed on Mon Sep 01, 2014 9:31 am, edited 1 time in total.

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

### Re: 10451 - Ancient Village Sports

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