Poj 1265 pick Theorem

Source: Internet
Author: User
Pick theorem, January 1899
If it is set as a plane, a single vertex has multiple shapes with a grid point as a vertex, and its surface is regarded


WhereBTo compare the number of grid points in the world,IIt is the number of internal lattice points. The formula (8) is called the pick formula.

/** Poj 1265 * Fuqiang * ry, pick theorem * 2013/8/7 */# include <iostream> # include <cstdio> # include <cstdlib> # include <cstring> # include <algorithm> # include <queue> using namespace STD; # define INF 0x3f3f3fconst int maxn = 100 + 3; int ABS (int n) {return n> 0? N:-N;} struct point {int X; int y;} p [maxn]; int gcd (int x, int y) {return y = 0? X: gcd (Y, X % Y);} int grid_onedge (int n) // point {int ret = 0; For (INT I = 0; I <n; I ++) {RET + = gcd (ABS (P [I]. x-P [(I + 1) % N]. x), ABS (P [I]. y-P [(I + 1) % N]. y);} return ret;} int grid_inside (int n) {int ret = 0; For (INT I = 0; I <n; I ++) {RET + = P [(I + 1) % N]. y * (p [I]. x-P [(I + 2) % N]. x);} return ABS (RET);} int main () {# ifndef online_judge freopen ("in", "r", stdin); # endif int t, case = 1; int n, a, B; CIN> T; while (t --) {CIN> N; P [0]. X = 0; P [0]. y = 0; For (INT I = 1; I <= N; I ++) {CIN> A> B; P [I % N]. X = P [I-1]. X + A; P [I % N]. y = P [I-1]. Y + B;} int e = grid_onedge (n); int I = (grid_inside (N)-E)/2 + 1; // number of internal cells double A = E/2.0 + I-1; printf ("Scenario # % d: \ n % d %. 1f \ n ", Case ++, I, e, a);} return 0 ;}

Evaluate the pick formula of the surface weight (
6 rows)

  1
Other Calculation Formula

The multi-plane shape on the plane has a variety of surface plane formulas, depending on the number given by the terminal plane. In addition to the pick formula introduced in this article, the heron formula and the regression formula form three important formulas for surface evaluation.

   
  2
Heron formula and its push

For a triangle, if we know the length of a triggerA,B,C, So that the surface is


There are two situations in which I pushed the question to the four charts. cai yiming, "Four-dimensional facial recognition", "Data Broadcast", vol. 17th, stage 3, China National People's Republic of China)

(I) When the four-dimensional Growth A, B, C, DAnd when it comes to the first hour, it is assumed that


This is called the Brahmagupta formula.

(Ii) for any four shapes, the surface is


WhereBAndDTo the right corner of a four-character pair. This is called the bretschneider formula. It is worth noting that it will not work if you want to push the code to the fifth or above.

   
  3
Formula for determining the number of samples (a surveyor's formula)

One NBorder shape A1, A2 ,..., A NThe cursor is configured in the reverse direction and A K= ( X K, Y K), K= 1, 2 ,..., N, In principle


RulesXN+ 1 =X1, andYN+ 1 =Y1.

Among the above three formulas, the attention formula should be the most powerful, because it can be "simplified 」. For example:

Fengqu in the reverse direction of the planeX=X(T),Y=Y(T), The plane of the completed domain is:


If we continue to push the attention, we will get the famous Green theorem, and the solution will be the mainstream in analytics. It seems to be a great river. Along the way, the branches of the river are collected, and finally they flow into the sea.

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.