Fence X50966


Statement
 

pdf   zip

html

John Zynoulus has a garden full of blue-black flowers. They are arranged in a square grid pattern.

However, Measharan scientists warn that there is a risk of a red rabbit invasion. The rabbits like to eat blue-black flowers, so John needs to put a fence to protect some of our flowers. For reasons of simplicity and aesthetics, we have decided that our fence will have a polygonal shape, and each of its vertices will be placed where a flower originally was. For example, the fence below protects 7 blue-black flowers from red rabbits.

John has designed the shape of the fence, but has some problems with calculating the number of blue-black flowers inside it. Can you help him?

Input

The first line contains the number of vertices N, 3 ≤ N ≤ 100000.

i-th of the following next N lines contains coordinates xi, yi of the i-th vertex of the polygon, where |xi|, |yi| ≤ 10000. Each pair (xi, yi) is distinct, and edges of our polygon don’t intersect (except in vertices).

Output

Output the number of grid points inside the polygon.

Public test cases
  • Input

    4
    0 0
    3 0
    3 3
    0 6
    

    Output

    7
    
  • Information
    Author
    Eryk Kopczynski
    Language
    English
    Official solutions
    Unknown.
    User solutions
    C++