Skip to content

Instantly share code, notes, and snippets.

@Luzhiled
Created June 28, 2017 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Luzhiled/888e78eb477db7ba199d0d7d066605ca to your computer and use it in GitHub Desktop.
Save Luzhiled/888e78eb477db7ba199d0d7d066605ca to your computer and use it in GitHub Desktop.
ARC018-B 格子点と整数
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back
using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;
const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }
lint gcd(lint a, lint b) {
if (b == 0) return a;
return gcd(b, a % b);
}
int main() {
int n = in();
vector<lint> x, y;
rep(i, n) {
x.pb(in());
y.pb(in());
}
lint ans = 0;
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
for (int k = j + 1; k < n; ++k) {
if ((y[i] - y[j]) * (x[j] - x[k]) == (x[i] - x[j]) * (y[j] - y[k])) continue;
lint a = gcd(abs(x[i] - x[j]), abs(y[i] - y[j]));
lint b = gcd(abs(x[j] - x[k]), abs(y[j] - y[k]));
lint c = gcd(abs(x[k] - x[i]), abs(y[k] - y[i]));
if ((a + b + c) % 2 == 0) ans++;
}
}
}
print(ans);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment