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

谁能帮我看看哪里错了啊。

Posted by banana at 2005-07-30 00:02:15 on Problem 2500
#include<iostream>
#include<cmath>
#include<memory>
#include<iomanip>
#include<algorithm>
using namespace std;
double pi = acos(-1.0);
double r;
int n,c,g;
int point[1001]; 
double Area(int n1,int n2);
bool Flag ;
int main()
{ 
	int n_case,i,j,k;
	cin>>n_case;
	for(i = 1; i <= n_case; i ++)
	{
		cout<<"Scenario #"<<i<<":"<<endl;
		cin>>r>>n>>c>>g;
		r/=2.0; 
		//find suitbale points
		memset(point,0,sizeof(point));
		for(j = 0 ;j < c; j++ )
			point[j] = g*j%n;
		sort(point,point+c);

		double area = 0.00;
		double a1,a2,a3;
		int tn; 
		for(j = 2; j < c-1;j ++)
		{
			tn = (point[j]/2.0);
			k = 1 ;
			
			while(point[k] < tn) k++;
			a1 = Area(0,k)+Area(k,j);
			a2 = Area(0,k-1) + Area(k-1,j);
			if(a1<a2) a1 = a2;

			tn = (point[j]+n)/2;
			k = j+1;
			while(point[k] < tn) k++;
			a2 = Area(j,k)+Area(k,0);
			a3 = Area(j,k-1)+Area(k-1,0);
			if(a2<a3) a2 = a3;

			if(area < a1+a2) area = a1+a2;
		} 
		cout<<setiosflags(ios::fixed)<<setprecision(6)<<area<<endl<<endl;
	}
	return 0;
} 
double Area(int n1,int n2)
{
	return r*r*sin(2*pi/n*((point[n2]+n-point[n1])%n))/2;
}

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