标签:des style blog ar io os sp for on
Description
Input
Output
Sample Input
1 4 -1.00 0.00 0.00 -3.00 2.00 0.00 2.00 2.00
Sample Output
2.00
Source
思路: 枚举计算
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int MAXN = 150;
const double INF = 100000000.0;
struct node {
double x, y;
} point[MAXN];
int n;
double dis(int a, int b) {
return sqrt((point[a].x-point[b].x)*(point[a].x-point[b].x)+(point[a].y-point[b].y)*(point[a].y-point[b].y));
}
double cal(int a, int b, int c) {
double A = dis(a, b);
double B = dis(a, c);
double C = dis(b, c);
double p = (A+B+C)/2;
return sqrt(p*(p-A)*(p-B)*(p-C));
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%lf%lf", &point[i].x, &point[i].y);
double ans = 1e20;
int flag = 0;
for (int i = 0; i < n; i++)
for (int j = i+1; j < n; j++)
for (int k = j+1; k < n; k++) {
double tmp = cal(i, j, k);
if (fabs(tmp) >= 0.01) {
flag = 1;
ans = min(ans, tmp);
}
}
if (!flag)
printf("Impossible\n");
else printf("%.2lf\n", ans);
}
}标签:des style blog ar io os sp for on
原文地址:http://www.cnblogs.com/mengfanrong/p/4172789.html