Water Testing Gym - 101873G

https://cn.vjudge.net/problem/Gym-101873G

总结:

皮克定理: S=a+b/2−1,其中 S 是多边形面积,a 是多边形内部格点数目,b 是多边形边界上的格点数目。

对于两端点(x1,y1),(x2,y2) 都再格点上的一条线段,该线段上的格点数目为 gcd(|x1−x2|,|y1−y2|)+1;

叉乘是三角形面积两倍;

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
//#include
using namespace std;

#define sfi(i) scanf("%d",&i)
#define sfl(i) scanf("%I64d",&i)
#define sfs(i) scanf("%s",(i))
#define pri(i) printf("%d\n",i)
#define prl(i) printf("%I64d\n",i)
#define sff(i) scanf("%lf",&i)
#define ll long long
#define ull unsigned long long
#define mem(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define inf 1e18
#define eps 1e-10
#define PI acos(-1.0)
#define lowbit(x) ((x)&(-x))
#define fl() printf("flag\n")
#define MOD(x) ((x%mod)+mod)%mod
#define endl '\n'
#define pb push_back
#define lson (rt<<1)
#define rson (rt<<1|1)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

templateinline void read(T &x)
{
    x=0;
    static int p;p=1;
    static char c;c=getchar();
    while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
    while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-48);c=getchar();}
    x*=p;
}

//-----------------------------------------------

const int maxn=1e5+9;
const int mod=1e9+7;

struct point
{
    ll x,y;
}p[maxn];

ll chax(point a,point b)
{
    return a.x*b.y-a.y*b.x;
}

int main()
{
    //FAST_IO;
    //freopen("input.txt","r",stdin);

    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>p[i].x>>p[i].y;

    ll s=0;

    for(int i=1;i

 

你可能感兴趣的:(公式,皮克定理)