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

Не пойму ошибку???
Posted by Xapl 22 Mar 2010 00:00
#include <iostream>
#include <math.h>
using namespace std;
const double pi=3.1415926535897932;
int main()
{
    int a;
    int n;
    double r;
    double *x,*y;
    x=new double;
    y=new double;
    double P=0;
    cin>>n;
    cin>>r;
    for(a=0;a<n;a++)
    {
        cin>>x[a];
        cin>>y[a];
    }
    for(a=0;a<n;a++)
    {
        P+=sqrt((x[a+1]-x[a])*(x[a+1]-x[a])+(y[a+1]-y[a])*(y[a+1]-y[a]));
    }
    P+=pi*r*(n-2);
    P=double(int(P*100))/100;
    cout<<P;
    return 0;
}
это код
Помогите Плиз
Re: Не пойму ошибку???
Posted by Alexey Berkunsky 30 Mar 2010 22:10
PI лучше писать как pi = 2.0*acos(0.0)
а формула же 2*Pi*r

Edited by author 30.03.2010 22:31