Pagini recente » Cod sursa (job #1006911) | Cod sursa (job #234626) | Cod sursa (job #1810175) | Cod sursa (job #60947) | Cod sursa (job #2849739)
#include <iostream>
#define NMAX 100005
using namespace std;
typedef long long ll;
struct elem {
int x, y;
} a[NMAX];
int n;
inline int cmmdc(int x, int y) {
while(y) {
int z = x % y;
x = y, y = z;
}
return x;
}
inline int vabs(const int x) {
return x > 0 ? x : -x;
}
ll calcArie() {
/*
|x1 y1|
|x2 y2|
*/
ll ans = 0;
for(int i = 1; i <= n; ++i)
ans += 1ll * a[i - 1].x * a[i].y - 1ll * a[i].x * a[i - 1].y;
return ans;
}
ll calcP() {
ll ans = 0;
for(int i = 1; i <= n; ++i)
ans += cmmdc(vabs(a[i].x - a[i - 1].x), vabs(a[i].y - a[i - 1].y));
return ans;
}
int main()
{
freopen("copaci.in", "r", stdin);
freopen("copaci.out", "w", stdout);
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%d%d", &a[i].x, &a[i].y);
a[0] = a[n];
cout << (calcArie() - calcP()) / 2 + 1;
return 0;
}