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

## 这么算为啥怎么都不对 谁有测试数据啊？

Posted by OmegaColeman at 2014-08-19 22:01:42 on Problem 1265
```#include <stdio.h>

int xs[110];
int ys[110];
int m;
int xmax;
int xmaxp;
double area;

#define MAX(a, b) (((a>b)?(a):(b)))

double get_area(int deltax, int pay, int pby)
{
return (pay + pby) * deltax * 0.5;
}

int calculate_points_inside()
{
int lb = 0;
int ldb = 0;
int points = 0;
int cdp = 0;
int cp = m - 1;
double k, b;
double ku, bu;
int i, v;
for(i = 0; i < xmax; i++)
{
int ca, cb;
if (i < ldb)
ca = (int)(k * i + b) + 1;
if (i < lb)
cb = (int)(ku * i + bu);
if(xs[cdp] == xs[cdp+1])
{
ca = MAX(ys[cdp], ys[cdp+1]);
} else {
k = (ys[cdp] - ys[cdp+1]) / (xs[cdp] - xs[cdp+1]);
b = ys[cdp] - k * xs[cdp];
ldb = xs[cdp + 1];
ca = ys[cdp];
}
if(xs[cp] == xs[cp-1])
{
cb = MAX(ys[cp], ys[cp-1]);
} else {
ku = (ys[cp] - ys[cp-1]) / (xs[cp] - xs[cp-1]);
bu = ys[cp] - ku * xs[cp];
lb = xs[cp - 1];
cb = ys[cp];
}
v = cb - ca;
points += (v > 0) ? (v - 1) : 0;
}
return points;
}

int main(void)
{
int n;
int ohfuck;
scanf("%d", &n);
for(ohfuck = 1; ohfuck <= n; ohfuck++)
{
int cx = 0;
int cy = 0;
int i, pi;
scanf("%d", &m);
xmax = -1;
area = 0;
for(i = 0; i < m; i++)
{
int dx, dy;
xs[i] = cx;
ys[i] = cy;
scanf("%d%d", &dx, &dy);
if ((xmax == -1) && (dx < 0))
{
xmax = cx;
xmaxp = i;
}
cx += dx;
cy += dy;
if (xmax == -1)
{
area -= get_area(dx, ys[i], cy);
} else {
area += get_area(-dx, ys[i], cy);
}
}
pi = calculate_points_inside();
printf("Scenario #%d:\n%d %d %.1lf\n\n", ohfuck, pi, (int)(((area - (double)pi + 1.) * 2.)), area);
}
return 0;
}

Followed by: