比赛 |
ZLXOI2015Day2 |
评测结果 |
AAAAAAWWWW |
题目名称 |
妹妹的饼干 |
最终得分 |
60 |
用户昵称 |
zero_std |
运行时间 |
0.003 s |
代码语言 |
C++ |
内存使用 |
0.32 MiB |
提交时间 |
2015-10-30 21:35:04 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <stack>
#include <algorithm>
#include <string>
#include <vector>
#include <ctime>
#include <bitset>
#include <cmath>
typedef long long LL;
#define INF 0x3f3f3f3f
using namespace std;
struct Edge {
int u, v, w;
};
struct Point {
int x, y;
};
template <class T> inline T min(T a, T b) {
return a > b ? b : a;
}
template <class T> inline T max(T a, T b) {
return a < b ? b : a;
}
template <class T> inline T abs(T a) {
return a > 0 ? a : -a;
}
template <class T> inline void CLR(T *a, int num) {
memset(a, num, sizeof(a));
}
int N;
Point point[1030];
LL ans, T, S;
inline void in() {
scanf("%d", &N);
for(int i = 0;i < N;i ++) scanf("%d%d", &point[i].x, &point[i].y);
}
inline void getS() {
int i;
Point St = point[0];
for(i = 1;i < N - 1;i ++) {
S += ((point[i].x - St.x) * (point[i + 1].y - St.y)) - ((point[i + 1].x - St.x) * (point[i].y - St.y));
}
S = abs(S);
}
LL gcd(LL a, LL b) {
return b == 0 ? a : gcd(b, a % b);
}
inline void getT() {
int i, j;
LL c, d, x, y;
for(i = 0;i < N - 1;i ++) {
Point p1 = point[i], p2 = point[i + 1];
T += gcd(abs(p2.x - p1.x), abs(p2.y - p1.y));
}
Point p1 = point[N - 1], p2 = point[0];
T += gcd(abs(p2.x - p1.x), abs(p2.y - p1.y));
}
inline void solve() {
getS();
getT();
ans = (S - T) / 2 + 1;
cout << ans;
}
int main() {
freopen("sistercookies.in", "r", stdin);
freopen("sistercookies.out", "w", stdout);
in();
solve();
//while(1);
return 0;
}