| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:兄弟们,除了变量定义我的过程都贴了......救救我吧.....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(°ree[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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator