UVA 10283 - The Kissing Circles, getting WA

50 views
Skip to first unread message

Md. Abdulla Al Mamun Nayon

unread,
Dec 20, 2014, 10:40:03 AM12/20/14
to akab...@googlegroups.com
Problem link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1224

My concept in picture:


My Code:
#include <iostream>
#include <cstdio>
#include <cmath>
#define PI 2*acos(0.0)
#define EP 1e-6

using namespace std;

int main()
{
   
int n;
   
double R, r, c, t, t2, l, e, s;
   
while(scanf("%lf %d", &R, &n) != EOF){
       
if(R < EP){
            r
= 0;
            l
= 0;
            e
= 0;
       
}
       
else if(n == 1){
            r
= R;
            l
= 0;
            e
= 0;
       
}
       
else{
            t
= 2*PI/n;
            c
= R*sqrt(2 - 2*cos(t));
            r
= c*R/(2*R+c);
            t2
= acos(r/(R-r));
            l
= n*(sqrt(R*r*r*(R-(2*r))) - r*r*t2);
            e
= PI*(R*R - n*r*r) - l;
       
}
        printf
("%.10lf %.10lf %.10lf\n", r, l, e);
   
}
   
return 0;
}


there is wrong answers after the decimal point, Is taking PI is correct?

Md. Abdulla Al Mamun Nayon

unread,
Dec 20, 2014, 11:29:48 AM12/20/14
to akab...@googlegroups.com
Finally I got Accepted, My fault was taking n as integer.
Reply all
Reply to author
Forward
0 new messages