ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1729. Dead Man's Chest

WA #7
Posted by Petru Trimbitas 7 Oct 2011 00:59
here's my code. I've tried many testes but i've passed them\

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

double f(double r, double a) {
        double rad=(a*4*atan((double)1))/180;
        double da=sqrt(
        2*r*r-2*r*r*cos(rad)
        );
        return da;
}

int main()
{
        double r,a,re,da,nr,rad;
        cin>>r>>a;
        re=r;
        nr=floor((double)180/a);
        da=f(r,2*a);
        re+=((nr-1)*da);
        double mod=360-floor(360/(2*a))*(2*a);
        //cout<<mod<<'\n';
        if(mod) re+=f(r,mod);
        cout<<fixed<<setprecision(6)<<re;
        return 0;
}