Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这个pi真精确啊

Posted by frkstyc at 2005-07-26 15:18:56 on Problem 2500
In Reply To:我的为什么一直WA? Posted by:liberty752 at 2005-07-25 17:24:08
> #include "stdio.h"
> #include "math.h"
> #define pi 3.1415926535897932384626433832795028841971
> int d,n,c,g;
> int k,cs[1001];
> double average;
> void sort()
> {int i,j,temp;
>  for(i=1;i<c;i++)
>   for(j=1;j<c-i+1;j++)
>   if(cs[j]>cs[j+1])
>   {temp=cs[j];
>    cs[j]=cs[j+1];
>    cs[j+1]=temp;
>   }
> }     
> double max(double a,double b)
> {if(a>b) return a;
>  else return b;
> } 
> 
> double sin1(int i,int j)
> {  if(j==1)
>     return sin(average*(n-cs[i])*pi/180);
>    else
>    return sin(average*(cs[j]-cs[i])*pi/180);
> }
> double comarea()
> {int i,j,t;
>  int sign1,sign2;
>  int mid;
>  double area1,area2,aread;
>  aread=0;
>  for(t=3;t<=c-1;t++)
>  {mid=(cs[1]+cs[t])/2;
>   for(i=2;i<t&&cs[i]<mid;i++);
>   if(i>=t) 
>    area1=sin1(1,i-1)+sin1(i-1,t);
>   else 
>    area1=max(sin1(1,i)+sin1(i,t),sin1(1,i-1)+sin1(i-1,t));
>   mid=(cs[t]+n)/2;
>   for(j=t+1;j<c+1&&cs[j]<mid;j++);
>   if(j>=c+1)
>    area2=sin1(t,j-1)+sin1(j-1,1);
>   else
>    area2=max(sin1(t,j)+sin1(j,1),sin1(t,j-1)+sin1(j-1,1));
>   if(area1+area2>aread) 
>     aread=area1+area2;
>  }
> return (0.125*d*d*aread);
> }     
> 
> 
> int main()
> {int scenario;
>  int i,j,count=0;
>  double area;
>  scanf("%d",&scenario);
>  while(scenario--)
>  {scanf("%d%d%d%d",&d,&n,&c,&g);
>   for(i=1,k=0;k<c;i++,k++)
>   cs[i]=(g*k)%n;
>   sort();
>   average=360*1.0/n;
>   area=comarea();
>   printf("Scenario #%d:\n",++count);
>   printf("%.6lf\n\n",area);
>  }
> return 0;
> }   

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator