#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) #define all(c) (c).begin(), (c).end() #define zero(a) memset(a, 0, sizeof a) #define minus(a) memset(a, -1, sizeof a) #define minimize(a, x) a = std::min(a, x) #define maximize(a, x) a = std::max(a, x) typedef long long ll; int const inf = 1<<29; #define double long double const double EPS = 1e-8; const double INF = 1e12; typedef complex P; namespace std { bool operator < (const P& a, const P& b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } } double cross(const P& a, const P& b) { return imag(conj(a)*b); } double dot(const P& a, const P& b) { return real(conj(a)*b); } struct L : public vector

{ L(const P &a, const P &b) { push_back(a); push_back(b); } }; typedef vector

G; struct C { P p; double r; C(const P &p, double r) : p(p), r(r) { } }; typedef P point; int ccw(P a, P b, P c) { b -= a; c -= a; if (cross(b, c) > 0) return +1; // counter clockwise if (cross(b, c) < 0) return -1; // clockwise if (dot(b, c) < 0) return +2; // c--a--b on line if (norm(b) < norm(c)) return -2; // a--b--c on line return 0; } bool intersectLL(const L &l, const L &m) { return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel abs(cross(l[1]-l[0], m[0]-l[0])) < EPS; // same line } bool intersectLS(const L &l, const L &s) { return cross(l[1]-l[0], s[0]-l[0])* // s[0] is left of l cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l } bool intersectLP(const L &l, const P &p) { return abs(cross(l[1]-p, l[0]-p)) < EPS; } bool intersectSS(const L &s, const L &t) { return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0; } bool intersectSP(const L &s, const P &p) { return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality } // a1,a2を端点とする線分とb1,b2を端点とする線分の交点計算 P intersection_ls(P a1, P a2, P b1, P b2) { P b = b2-b1; double d1 = abs(cross(b, a1-b1)); double d2 = abs(cross(b, a2-b1)); double t = d1 / (d1 + d2); return a1 + (a2-a1) * t; } P intersection_ls(L const& s1, L const& s2) { return intersection_ls(s1[0], s1[1], s2[0], s2[1]); } typedef vector

polygon; enum { OUT, ON, IN }; int convex_contains(const polygon &P, const point &p) { const int n = P.size(); point g = (P[0] + P[n/3] + P[2*n/3]) / (double)3.0; // inner-point int a = 0, b = n; while (a+1 < b) { // invariant: c is in fan g-P[a]-P[b] int c = (a + b) / 2; if (cross(P[a]-g, P[c]-g) > 0) { // angle < 180 deg if (cross(P[a]-g, p-g) > 0 && cross(P[c]-g, p-g) < 0) b = c; else a = c; } else { if (cross(P[a]-g, p-g) < 0 && cross(P[c]-g, p-g) > 0) a = c; else b = c; } } b %= n; if (cross(P[a] - p, P[b] - p) < 0) return 0; if (cross(P[a] - p, P[b] - p) > 0) return 2; return 1; } typedef double number; #define prev(P, i) ( P[(i-1 + P.size()) % P.size()] ) #define curr(P, i) ( P[i % P.size()] ) #define next(P, i) ( P[(i+1) % P.size()] ) vector convex_hull(vector ps) { int n = ps.size(), k = 0; sort(ps.begin(), ps.end()); vector ch(2*n); for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k; for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k; ch.resize(k-1); return ch; } int is_point_on_line(point a, point b, point c) { return ( cross(b-a, c-a), 0.0 ) <= EPS; } polygon convex_cut(const polygon& P, const L& l) { polygon Q; for (int i = 0; i < P.size(); ++i) { point A = curr(P, i), B = next(P, i); if (ccw(l[0], l[1], A) != -1) Q.push_back(A); if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0) Q.push_back(intersection_ls(L(A, B), l)); } return Q; } polygon convex_and(const polygon& g, const polygon& h) { polygon r = g; rep(i, h.size()) { r = convex_cut(r, L(h[i],h[(i+1)%h.size()])); } return r; } number area2(const polygon& P) { number A = 0; for (int i = 0; i < P.size(); ++i) A += cross(curr(P, i), next(P, i)); return A; } long long PickGetI(double S, double b) { return ceil(S - b / 2.0 + 1); } int main() { double x1, y1, x2, y2, d; cin >> x1 >> y1 >> x2 >> y2 >> d; polygon D; D.emplace_back(d, 0); D.emplace_back(0, d); D.emplace_back(-d, 0); D.emplace_back(0, -d); polygon R; R.emplace_back(x1, y1); R.emplace_back(x2, y1); R.emplace_back(x2, y2); R.emplace_back(x1, y2); auto C = convex_and(D, R); ll b = 0; rep(i, C.size()) { auto& tar = C[(i+1)%C.size()]; auto& cur = C[i]; ll A = abs((ll)(tar.real() - cur.real())); ll B = abs((ll)(tar.imag() - cur.imag())); if(A == 0) { b += B; } else if(B == 0) { b += A; } else { b += __gcd(A, B); } } cout << PickGetI(area2(C) / 2, b) + b << endl; return 0; }