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

Common Board

Please, help me!!! I get WA in simple problem 1020. I tried to submit this solve many times. But I always get WA!
Posted by Bedny Yuri (bedny@rain.ifmo.ru) 19 Jun 2002 17:06
#include <iostream.h>
#include <math.h>

struct tPt{double x,y;}p1,p2,fs;

int n;
double dx,dy,r,l;
const double PI=3.141592;

int main()
{
  cin>>n>>r>>p1.x>>p1.y;
  fs=p1;
  l=2*PI*r;
  for (int i=1;i<n;i++)
  {
    cin>>p2.x>>p2.y;
    dx=p2.x-p1.x;dy=p2.y-p1.y;
    l+=sqrt(dx*dx+dy*dy);
    p1=p2;
  }
  if (n>1)
  {
    dx=p1.x-fs.x;dy=p1.y-fs.y;
    l+=sqrt(dx*dx+dy*dy);
  }
  cout.precision(2);
  cout<<l;
  return 0;
}
Problem with precision (+)
Posted by Andrey Popyk (popyk@ief.tup.km.ua) 20 Jun 2002 12:42
try this:

l=3.00000
cout.precision(2);
cout<<l;

the result is 3 (not 3.00)

that after using cout, use printf for output float and double with
precision.
Ehich problem is this?
Posted by I am david. Tabo. 25 Jun 2002 23:30