HDU 2036 reform Spring breeze blowing everywhere (calculate geometry)

Source: Internet
Author: User

Test instructions: you know.

Analysis: There is nothing to say, to find the area with a fork, try not to use Helen Formula, because the computational capacity is large, but also the loss of precision.

The code is as follows:

#include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <set># Include <vector> #include <algorithm>using namespace Std;const int maxn = + 5;int X[MAXN], y[maxn];int Cros s (int x1, int y1, int x2, int y2) {    return x1 * y2-x2 * y1;} int main () {    int n;    while (scanf ("%d", &n) = = 1 && N) {        for (int i = 0; i < n; ++i)  scanf ("%d%d", &x[i], &y[i]); C6/>x[n] = x[0];  Y[n] = y[0];        double s = 0.0;        for (int i = 0; i < n; ++i)  S + = Cross (X[i], y[i], x[i+1], y[i+1]);        printf ("%.1lf\n", s/2.0);}    }

HDU 2036 reform Spring breeze blowing everywhere (calculate geometry)

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.