Usaco 3.4 Electric Fence pique theorem

Source: Internet
Author: User

Test instructions: Draw a triangle on the checkered paper to find the number of lattice points contained within the triangle

Because one of the edges is the x-axis, the first thing to think about is to figure out the corresponding mathematical function for two edges, and then enumerate the x-coordinate values for solving. But it doesn't have to be that troublesome.

Pique theorem: given vertex coordinates are simple polygons of the whole point (or square lattice), the pique theorem illustrates the relationship between the area A and the number of inner lattice points i, and the number of lattice points on the edge: A = I + b/2-1.

It's a good rule to have this theorem.

The triangular area can be calculated directly with the formula.

For segments from points (0,0) to point (x, y), the number of lattice points on that segment is gcd (x, y) +1

So A and b all have, set the formula on the line.

Usaco 3.4 Electric Fence pique theorem

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.