HDU-4709 Herding

Source: Internet
Author: User

Description

Little John is herding He father ' s cattles. As a lazy boy, he cannot tolerate chasing the cattles all the time to avoid unnecessary omission. Luckily, he notice, were n trees in the meadow numbered from 1 to N, and calculated their Cartesian coordinates (Xi, Yi). To herding his cattles safely, the easiest-on-is-connect some of the trees (with different numbers, of course) with FE NCEs, and the close region they formed would is herding area. Little John wants the area of this region to is as small as possible, and it could not being zero, of course.

Input

The first line contains the number of test cases T (t<=25). Following lines is the scenarios of each test case.
The first line of all test case contains one integer N (1<=n<=100). The following N lines describe the coordinates of the trees. Each of these lines would contain-float numbers Xi and Yi ( -1000<=xi, yi<=1000) representing the coordinates of The corresponding tree. The coordinates of the trees would not be coincide with each other.

Output

For each test case, please output one number rounded to 2 digits after the decimal point representing the area of the Smal Lest region. Or output "impossible" (without quotations), if it does not exists such a region.

Sample Input

Sample Output

Source

ACM/ICPC Asia Regional Online――warmup

IDEA: Enumeration calculation

#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);d ouble b = dis (A, c);d ouble c = dis (b, c);d ouble p = (a+b+c)/2;retur n 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);d ouble 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);}}



HDU-4709 Herding

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.