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

Re:兄弟们,除了变量定义我的过程都贴了......救救我吧.....

Posted by c0500448242 at 2005-07-22 12:04:35 on Problem 2500
In Reply To:兄弟们,除了变量定义我的过程都贴了......救救我吧..... Posted by:Bluebird at 2005-07-22 11:59:41
//我贴一个,基本上就是你的程序.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAXN 1000
#define PI 3.14159265359

int degree[MAXN+1];
double point[MAXN+1][2];
int n,c,d;
double alph;

int Cmp(const void *a, const void *b)
{
	return *(const int *)a - *(const int *)b;
}

double Sum(int a,int b,int c)
{
	double x1, y1, x2, y2, x3, y3;
	a = degree[a], b = degree[b], c = degree[c];
	x1 = d * cos(a * alph) / 2.0;
	y1 = d * sin(a * alph) / 2.0;
	x2 = d * cos(b * alph) / 2.0;
	y2 = d * sin(b * alph) / 2.0;
	x3 = d * cos(c * alph) / 2.0;
	y3 = d * sin(c * alph) / 2.0;
	return fabs(x1 * y3 + x2 * y1 + x3 * y2 - x1 * y2 - x2 * y3 - x3 * y1) / 2.0;

}

double Solve()
{
	int i,f1,f2,mid;
	double s1,s2,s;
	double max;
	max = 0.0;
	f1 = 1, f2 = 3;
	for(i=3;i<c;i++)
	{
		mid = degree[i] / 2;
		while ((f1 < i - 1) && (degree[f1] < mid)) f1 ++;
		s1 = Sum(f1,i,1);
		s = Sum(f1-1,i,1);
		s1 = s1 > s ? s1 : s;
		mid = (n + degree[i]) / 2;
		while ((f2 < c) && (degree[f2] < mid)) f2 ++;
		s2 = Sum(f2,i,1);
		s = Sum(f2-1,i,1);
		s2 = s2 > s ? s2 : s;
		if(s1 + s2 > max)
		{
			max = s1 + s2;
		}
	}
	return max;
}


int main()
{
	int i,g;
	double th;
	int ca, t = 0;
	scanf("%d",&ca);
	while(ca-- > 0)
	{
		t ++;
		scanf("%d %d %d %d",&d,&n,&c,&g);
		for(i=0;i<c;i++)
		{
			degree[i+1] = (int)(((__int64)i * g) % (__int64)n);
		}
		qsort(&degree[1],c,sizeof(degree[1]),Cmp);
		alph = 2 * PI / n;
		printf("Scenario #%d:\n",t);
		printf("%.6lf\n",Solve());
		printf("\n");
	}
	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