Problem:
勇猛果敢なイクタ君はついに悪名高きビッグブリッジ伯爵を追い詰めた！　今やビッグブリッジ伯爵は幅
w
メートル、奥行き
h
メートルの長方形の部屋に閉じ込められており、最期を待つばかりとなっている。
部屋のある角を選び、幅方向を
x
軸、奥行き方向を
y
軸に、それぞれ部屋の内部が正の方向になるように座標系をとると、ビッグブリッジ伯爵は点
(p, q)
にいる。点
(x, y)
にイクタ君の最終兵器である衝撃波発射装置があり、ここから秒速
v
メートルの衝撃波を全方向に出す。この衝撃波は
t
秒間有効であり、部屋の壁面で反射する。
部屋の外にいるイクタ君はビッグブリッジ伯爵がどれだけ苦しむか知りたがっているので、ビッグブリッジ伯爵に衝撃波が何回当たるかを求めるプログラムを書いてあげよう。このとき、衝撃波が同時に
n
方向から敵に当たる場合は
n
回当たったとみなし、また衝撃波がちょうど
t
秒後に敵に当たる場合も有効であるとする。衝撃波は発射装置自身やビッグブリッジ伯爵などの障害物により消滅せず、衝撃波同士は干渉しない。
Input
入力は以下の形式で与えられる。
w
h
v
t
x
y
p
q
それぞれは問題文の説明の通りの正の整数である。
Constraints
v × t ≤ 10
6
2 ≤ w, h ≤ 10
8
0 < x, p < w
0 < y, q < h
(x, y) ≠ (p, q)
Output
衝撃波がビッグブリッジ伯爵に当たる回数を1行に出力せよ。
Sample Input 1
10 10 1 10 3 3 7 7
Output for the Sample Input 1
1
Sample Input 2
10 10 1 11 3 3 7 7
Output for the Sample Input 2
5
入力例 1, 2 において部屋の大きさと発射装置とビッグブリッジ伯爵の位置が同じであることに注意しながら、それぞれに付随する図（黒い点が発射装置、白い点がビッグブリッジ伯爵を表す）を見よ。
Sample Input 3
2 3 1000 1000 1 1 1 2
Output for the Sample Input 3
523598775681

Submitted solutions:

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

/**
 * @brief template
 */

int main() {
    ll MAXS = 1000000;
    ll N, M, V, T, X, Y, P, Q;
    cin >> N >> M >> V >> T >> X >> Y >> P >> Q;
    auto CalcX = [&](ll A) -> ll {
        if (abs(A) % 2 == 0) return A*N+P;
        else return A*N+N-P;
    };
    auto CalcY = [&](ll A) -> ll {
        if (abs(A) % 2 == 0) return A*M+Q;
        else return A*M+M-Q;
    };
    ll ANS = 0;
    rep(i,-MAXS,MAXS) {
        ll A = CalcX(i);
        if (A < X - V * T) continue;
        if (X + V * T < A) continue;
        ll D = (V*T)*(V*T) - (A-X)*(A-X);
        if ((CalcY(0)-Y) * (CalcY(0)-Y) > D) continue;
        ll OK = 0, NG = MAXS;
        while(NG - OK > 1) {
            ll MID = (OK + NG) / 2;
            ll y = CalcY(MID);
            if (abs(y-Y) <= 1000000000 && (y-Y)*(y-Y) <= D) OK = MID;
            else NG = MID;
        }
        ll Right = OK;
        NG = -MAXS, OK = 0;
        while(OK - NG > 1) {
            ll MID = (OK + NG) / 2;
            ll y = CalcY(MID);
            if (abs(y-Y) <= 1000000000 && (y-Y)*(y-Y) <= D) OK = MID;
            else NG = MID;
        }
        ll Left = OK;
        ANS += Right - Left + 1;
    }
    cout << ANS << endl;
}
accuracy: 1
time_ms: 150
memory_kb: 3464
final_rank: 3

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

/**
 * @brief template
 */

int main() {
    ll MAXS = 1000000;
    ll N, M, V, T, X, Y, P, Q;
    cin >> N >> M >> V >> T >> X >> Y >> P >> Q;
    auto CalcX = [&](ll A) -> ll {
        if (abs(A) % 2 == 0) return A*N+P;
        else return A*N+N-P;
    };
    auto CalcY = [&](ll A) -> ll {
        if (abs(A) % 2 == 0) return A*M+Q;
        else return A*M+M-Q;
    };
    ll ANS = 0;
    rep(i,-MAXS,MAXS) {
        ll A = CalcX(i);
        if (A < X - V * T) continue;
        if (X + V * T < A) continue;
        ll D = (V*T)*(V*T) - (A-X)*(A-X);
        if ((CalcY(0)-Y) * (CalcY(0)-Y) > D) continue;
        ll OK = 0, NG = MAXS;
        while(NG - OK > 1) {
            ll MID = (OK + NG) / 2;
            ll y = CalcY(MID);
            if ((y-Y)*(y-Y) <= D) OK = MID;
            else NG = MID;
        }
        ll Right = OK;
        NG = -MAXS, OK = 0;
        while(OK - NG > 1) {
            ll MID = (OK + NG) / 2;
            ll y = CalcY(MID);
            if ((y-Y)*(y-Y) <= D) OK = MID;
            else NG = MID;
        }
        ll Left = OK;
        ANS += Right - Left + 1;
    }
    cout << ANS << endl;
}
accuracy: 0.6388888888888888
time_ms: 140
memory_kb: 3476
final_rank: 12

code_snippet: #line 1 "2609.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/2609"

#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Point.hpp"

#line 2 "/home/zawatin/compro/cp-documentation/Src/Template/TypeAlias.hpp"

#include <cstdint>
#include <cstddef>

namespace zawa {

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using i128 = __int128_t;

using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;

using usize = std::size_t;

} // namespace zawa
#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Zahlen.hpp"

#line 4 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Zahlen.hpp"

#include <cassert>

namespace zawa {

namespace geometryZ2 {

using Zahlen = i64;

namespace internal {

constexpr i32 positive{1};
constexpr i32 zero{0};
constexpr i32 negative{-1};

} // namespace internal

constexpr i32 Sign(Zahlen value) {
    if (value < 0) return internal::negative;
    if (value > 0) return internal::positive;
    return internal::zero;
}

constexpr bool Positive(Zahlen value) {
    return Sign(value) == internal::positive;
}

constexpr bool Zero(Zahlen value) {
    return Sign(value) == internal::zero;
}

constexpr bool Negative(Zahlen value) {
    return Sign(value) == internal::negative;
}

constexpr Zahlen Abs(Zahlen value) {
    return (value > 0 ? value : -value);
}

constexpr Zahlen Square(Zahlen value) {
    return value * value;
}

} // namespace geometryZ2

} // namespace zawa
#line 5 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Point.hpp"

#include <algorithm>
#include <iostream>
#line 9 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Point.hpp"
#include <limits>

namespace zawa {

namespace geometryZ2 {

class Point {
private:
    Zahlen x_{}, y_{};
    static constexpr i32 origin{0};
    static constexpr i32 firstQuadrant{1};
    static constexpr i32 secondQuadrant{2};
    static constexpr i32 thirdQuadrant{-2};
    static constexpr i32 forthQuadrant{-1};
public:
    /* constructor */
    Point() = default;
    Point(const Point& p) : x_{p.x()}, y_{p.y()} {}
    Point(Zahlen x, Zahlen y) : x_{x}, y_{y} {}

    /* getter setter */
    Zahlen& x() {
        return x_;
    }
    const Zahlen& x() const {
        return x_;
    }
    Zahlen& y() {
        return y_;
    }
    const Zahlen& y() const {
        return y_;
    }

    /* operator */
    Point& operator=(const Point& p) {
        x() = p.x();
        y() = p.y();
        return *this;
    }
    Point& operator+=(const Point& p) {
        x() += p.x();
        y() += p.y();
        return *this;
    }
    friend Point operator+(const Point& p0, const Point& p1) {
        return Point{p0} += p1;
    }
    Point& operator-=(const Point& p) {
        x() -= p.x();
        y() -= p.y();
        return *this;
    }
    friend Point operator-(const Point& p0, const Point& p1) {
        return Point{p0} -= p1;
    }
    Point& operator*=(Zahlen k) {
        x() *= k;
        y() *= k;
        return *this;
    }
    friend Point operator*(const Point& p, Zahlen k) {
        return Point{p} *= k;
    }
    friend Point operator*(Zahlen k, const Point& p) {
        return Point{p} *= k;
    }
    Point& operator/=(Zahlen k) {
        assert(k);
        assert(x() % k == 0);
        assert(y() % k == 0);
        x() /= k;
        y() /= k;
        return *this;
    }
    friend Point operator/(const Point& p, Zahlen k) {
        return Point{p} /= k;
    }
    friend bool operator==(const Point& p0, const Point& p1) {
        return p0.x() == p1.x() and p0.y() == p1.y();
    }
    friend bool operator!=(const Point& p0, const Point& p1) {
        return p0.x() != p1.x() or p0.y() != p1.y();
    }
    friend bool operator<(const Point& p0, const Point& p1) {
        if (p0.x() != p1.x()) return p0.x() < p1.x();
        else return p0.y() < p1.y();
    }
    friend bool operator<=(const Point& p0, const Point& p1) {
        return (p0 < p1) or (p0 == p1);
    }
    friend bool operator>(const Point& p0, const Point& p1) {
        if (p0.x() != p1.x()) return p0.x() > p1.x();
        else return p0.y() > p1.y();
    }
    friend bool operator>=(const Point& p0, const Point& p1) {
        return (p0 > p1) or (p0 == p1);
    }
    friend std::istream& operator>>(std::istream& is, Point& p) {
        is >> p.x() >> p.y();
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, const Point& p) {
        os << '(' << p.x() << ',' << p.y() << ')';
        return os;
    }

    /* member function */
    Zahlen normSquare() const {
        return Square(x()) + Square(y());
    }
    bool isNormSquareOver(Zahlen d) const {
        assert(!Negative(d));
        auto [mn, mx]{std::minmax({ Abs(x()), Abs(y()) })};
        if (mx and mx > d / mx) {
            return true;
        }
        long long s1{Square(mn)}, s2{Square(mx)};
        if (s1 > d - s2) {
            return true;
        }
        return false;
    }
    bool isNormSquareOverflow() const {
        return isNormSquareOver(std::numeric_limits<Zahlen>::max());
    }

    i32 area() const {
        if (x_ == 0 and y_ == 0) return origin;
        if (x_ <= 0 and y_ < 0) return thirdQuadrant;
        if (x_ > 0 and y_ <= 0) return forthQuadrant;
        if (x_ >= 0 and y_ > 0) return firstQuadrant;
        return secondQuadrant;
    }

    /* static member */
    static bool ArgComp(const Point& p0, const Point& p1) {
        if (p0.area() != p1.area()) return p0.area() < p1.area();
        Zahlen cross{Cross(p0, p1)};
        return (!Zero(cross) ? Positive(cross) : p0.normSquare() < p1.normSquare());
    }

    /* friend function */
    friend Zahlen Dot(const Point& p0, const Point& p1) {
        return p0.x() * p1.x() + p0.y() * p1.y();
    }
    friend Zahlen Cross(const Point& p0, const Point& p1) {
        return p0.x() * p1.y() - p0.y() * p1.x();
    }
};
using Vector = Point;

} // namespace geometryZ2

} // namespace zawa
#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Circle.hpp"

#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Distance/PointAndPoint.hpp"

#line 5 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Distance/PointAndPoint.hpp"

namespace zawa {

namespace geometryZ2 {

Zahlen DistanceSquare(const Point& p0, const Point& p1) {
    return Vector{p1 - p0}.normSquare();
}

} // namespace geometryZ2

} // namespace zawa
#line 7 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Circle.hpp"

#line 9 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Circle.hpp"

namespace zawa {

namespace geometryZ2 {

class Circle {
private:
    Point center_{};
    Zahlen radius_{};
public:
    /* constructor */
    Circle() = default;
    Circle(const Point& center, const Zahlen radius) : center_{center}, radius_{radius} {
        assert(!Negative(radius_));
    }

    /* getter, setter */
    Point& center() {
        return center_;
    }
    const Point& center() const {
        return center_;
    }
    Zahlen& radius() {
        return radius_;
    }
    const Zahlen& radius() const {
        return radius_;
    }

    /* operator */
    Circle& operator=(const Circle& c) {
        radius_ = c.radius();
        center_ = c.center();
        return *this;
    }
    friend bool operator==(const Circle& c0, const Circle& c1) {
        return c0.radius() == c1.radius() and c0.center() == c1.center();
    }
    friend bool operator!=(const Circle& c0, const Circle& c1) {
        return c0.radius() != c1.radius() or c0.center() != c1.center();
    }

    /* member */
    
    Zahlen radiusSquare() const {
        return Square(radius_);
    }

    /* friend function */
    friend u32 NumberCommonTangent(const Circle& c0, const Circle& c1) {
        Zahlen dist{DistanceSquare(c0.center(), c1.center())};
        Zahlen down{Square(Abs(c0.radius() - c1.radius()))};
        if (dist < down) {
            return 0;
        }
        if (dist == down) {
            return 1;
        }
        Zahlen up{Square(c0.radius() + c1.radius())}; 
        if (dist < up) {
            return 2;
        }
        if (dist == up) {
            return 3;
        }
        return 4;
    }
};

} // namespace geometryZ2

} // namespace zawa
#line 2 "/home/zawatin/compro/cp-documentation/Src/Utility/BinarySearch.hpp"

#line 4 "/home/zawatin/compro/cp-documentation/Src/Utility/BinarySearch.hpp"

#include <cmath>
#include <functional>
#include <type_traits>
#include <utility>

namespace zawa {

namespace internal {

template <class T>
T MidPoint(T a, T b) {
    if (a > b) std::swap(a, b);
    return a + ((b - a) >> 1);
}

template <class T>
T Abs(T a, T b) {
    return (a >= b ? a - b : b - a);
}

} // namespace zawa::internal

template <class T, class Function>
T BinarySearch(T ok, T ng, const Function& f) {
    static_assert(std::is_integral_v<T>, "T must be integral type");
    static_assert(std::is_convertible_v<Function, std::function<bool(T)>>, "f must be function bool(T)");
    while (internal::Abs(ok, ng) > 1) {
        T mid{ internal::MidPoint(ok, ng) };
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

template <class T, class Function>
T BinarySearch(T ok, T ng, const Function& f, u32 upperLimit) {
    static_assert(std::is_signed_v<T>, "T must be signed arithmetic type");
    static_assert(std::is_convertible_v<Function, std::function<bool(T)>>, "f must be function bool(T)");
    for (u32 _{} ; _ < upperLimit ; _++) {
        T mid{ (ok + ng) / (T)2 };
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

} // namespace zawa
#line 6 "2609.test.cpp"
using namespace zawa;
using namespace geometryZ2;

int main() {
    Zahlen W, H, V, T, X, Y, P, Q;
    std::cin >> W >> H >> V >> T >> X >> Y >> P >> Q;
    Circle wave{Point{ X, Y }, V * T};
    Zahlen ans{};
    auto hito{[&](Zahlen x, Zahlen y) -> Point {
        Point res{W * x, H * y};
        res.x() += (x % 2 ? W - P : P);
        res.y() += (y % 2 ? H - Q : Q);
        return res;
    }};
    auto contains{[&](Zahlen x, Zahlen y) -> bool {
        Point diff{wave.center() - hito(x, y)};
        return !diff.isNormSquareOver(wave.radiusSquare());
    }};
    for (Zahlen x{-1000000} ; x <= 1000000 ; x++) {
        if (!contains(x, 0)) continue;
        ans += BinarySearch(Zahlen{1000000}, Zahlen{0}, [&](Zahlen y) -> bool {
                return !contains(x, y);
                });
        ans -= BinarySearch(Zahlen{0}, Zahlen{-1000000}, [&](Zahlen y) -> bool {
                return contains(x, y);
                });
    }
    std::cout << ans << '\n';
}
accuracy: 1
time_ms: 360
memory_kb: 3440
final_rank: 8

code_snippet: #line 1 "2609.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/2609"

#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Point.hpp"

#line 2 "/home/zawatin/compro/cp-documentation/Src/Template/TypeAlias.hpp"

#include <cstdint>
#include <cstddef>

namespace zawa {

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using i128 = __int128_t;

using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;

using usize = std::size_t;

} // namespace zawa
#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Zahlen.hpp"

#line 4 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Zahlen.hpp"

#include <cassert>

namespace zawa {

namespace geometryZ2 {

using Zahlen = i64;

namespace internal {

constexpr i32 positive{1};
constexpr i32 zero{0};
constexpr i32 negative{-1};

} // namespace internal

constexpr i32 Sign(Zahlen value) {
    if (value < 0) return internal::negative;
    if (value > 0) return internal::positive;
    return internal::zero;
}

constexpr bool Positive(Zahlen value) {
    return Sign(value) == internal::positive;
}

constexpr bool Zero(Zahlen value) {
    return Sign(value) == internal::zero;
}

constexpr bool Negative(Zahlen value) {
    return Sign(value) == internal::negative;
}

constexpr Zahlen Abs(Zahlen value) {
    return (value > 0 ? value : -value);
}

constexpr Zahlen Square(Zahlen value) {
    return value * value;
}

} // namespace geometryZ2

} // namespace zawa
#line 5 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Point.hpp"

#include <algorithm>
#include <iostream>
#line 9 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Point.hpp"
#include <limits>

namespace zawa {

namespace geometryZ2 {

class Point {
private:
    Zahlen x_{}, y_{};
    static constexpr i32 origin{0};
    static constexpr i32 firstQuadrant{1};
    static constexpr i32 secondQuadrant{2};
    static constexpr i32 thirdQuadrant{-2};
    static constexpr i32 forthQuadrant{-1};
public:
    /* constructor */
    Point() = default;
    Point(const Point& p) : x_{p.x()}, y_{p.y()} {}
    Point(Zahlen x, Zahlen y) : x_{x}, y_{y} {}

    /* getter setter */
    Zahlen& x() {
        return x_;
    }
    const Zahlen& x() const {
        return x_;
    }
    Zahlen& y() {
        return y_;
    }
    const Zahlen& y() const {
        return y_;
    }

    /* operator */
    Point& operator=(const Point& p) {
        x() = p.x();
        y() = p.y();
        return *this;
    }
    Point& operator+=(const Point& p) {
        x() += p.x();
        y() += p.y();
        return *this;
    }
    friend Point operator+(const Point& p0, const Point& p1) {
        return Point{p0} += p1;
    }
    Point& operator-=(const Point& p) {
        x() -= p.x();
        y() -= p.y();
        return *this;
    }
    friend Point operator-(const Point& p0, const Point& p1) {
        return Point{p0} -= p1;
    }
    Point& operator*=(Zahlen k) {
        x() *= k;
        y() *= k;
        return *this;
    }
    friend Point operator*(const Point& p, Zahlen k) {
        return Point{p} *= k;
    }
    friend Point operator*(Zahlen k, const Point& p) {
        return Point{p} *= k;
    }
    Point& operator/=(Zahlen k) {
        assert(k);
        assert(x() % k == 0);
        assert(y() % k == 0);
        x() /= k;
        y() /= k;
        return *this;
    }
    friend Point operator/(const Point& p, Zahlen k) {
        return Point{p} /= k;
    }
    friend bool operator==(const Point& p0, const Point& p1) {
        return p0.x() == p1.x() and p0.y() == p1.y();
    }
    friend bool operator!=(const Point& p0, const Point& p1) {
        return p0.x() != p1.x() or p0.y() != p1.y();
    }
    friend bool operator<(const Point& p0, const Point& p1) {
        if (p0.x() != p1.x()) return p0.x() < p1.x();
        else return p0.y() < p1.y();
    }
    friend bool operator<=(const Point& p0, const Point& p1) {
        return (p0 < p1) or (p0 == p1);
    }
    friend bool operator>(const Point& p0, const Point& p1) {
        if (p0.x() != p1.x()) return p0.x() > p1.x();
        else return p0.y() > p1.y();
    }
    friend bool operator>=(const Point& p0, const Point& p1) {
        return (p0 > p1) or (p0 == p1);
    }
    friend std::istream& operator>>(std::istream& is, Point& p) {
        is >> p.x() >> p.y();
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, const Point& p) {
        os << '(' << p.x() << ',' << p.y() << ')';
        return os;
    }

    /* member function */
    Zahlen normSquare() const {
        return Square(x()) + Square(y());
    }
    bool isNormSquareOver(Zahlen d) const {
        assert(!Negative(d));
        auto [mn, mx]{std::minmax({ Abs(x()), Abs(y()) })};
        if (mn and mx > d / mn) {
            return true;
        }
        long long s1{Square(mn)}, s2{Square(mx)};
        if (s1 > d - s2) {
            return true;
        }
        return false;
    }
    bool isNormSquareOverflow() const {
        return isNormSquareOver(std::numeric_limits<Zahlen>::max());
    }

    i32 area() const {
        if (x_ == 0 and y_ == 0) return origin;
        if (x_ <= 0 and y_ < 0) return thirdQuadrant;
        if (x_ > 0 and y_ <= 0) return forthQuadrant;
        if (x_ >= 0 and y_ > 0) return firstQuadrant;
        return secondQuadrant;
    }

    /* static member */
    static bool ArgComp(const Point& p0, const Point& p1) {
        if (p0.area() != p1.area()) return p0.area() < p1.area();
        Zahlen cross{Cross(p0, p1)};
        return (!Zero(cross) ? Positive(cross) : p0.normSquare() < p1.normSquare());
    }

    /* friend function */
    friend Zahlen Dot(const Point& p0, const Point& p1) {
        return p0.x() * p1.x() + p0.y() * p1.y();
    }
    friend Zahlen Cross(const Point& p0, const Point& p1) {
        return p0.x() * p1.y() - p0.y() * p1.x();
    }
};
using Vector = Point;

} // namespace geometryZ2

} // namespace zawa
#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Circle.hpp"

#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Distance/PointAndPoint.hpp"

#line 5 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Distance/PointAndPoint.hpp"

namespace zawa {

namespace geometryZ2 {

Zahlen DistanceSquare(const Point& p0, const Point& p1) {
    return Vector{p1 - p0}.normSquare();
}

} // namespace geometryZ2

} // namespace zawa
#line 7 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Circle.hpp"

#line 9 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Circle.hpp"

namespace zawa {

namespace geometryZ2 {

class Circle {
private:
    Point center_{};
    Zahlen radius_{};
public:
    /* constructor */
    Circle() = default;
    Circle(const Point& center, const Zahlen radius) : center_{center}, radius_{radius} {
        assert(!Negative(radius_));
    }

    /* getter, setter */
    Point& center() {
        return center_;
    }
    const Point& center() const {
        return center_;
    }
    Zahlen& radius() {
        return radius_;
    }
    const Zahlen& radius() const {
        return radius_;
    }

    /* operator */
    Circle& operator=(const Circle& c) {
        radius_ = c.radius();
        center_ = c.center();
        return *this;
    }
    friend bool operator==(const Circle& c0, const Circle& c1) {
        return c0.radius() == c1.radius() and c0.center() == c1.center();
    }
    friend bool operator!=(const Circle& c0, const Circle& c1) {
        return c0.radius() != c1.radius() or c0.center() != c1.center();
    }

    /* member */
    
    Zahlen radiusSquare() const {
        return Square(radius_);
    }

    /* friend function */
    friend u32 NumberCommonTangent(const Circle& c0, const Circle& c1) {
        Zahlen dist{DistanceSquare(c0.center(), c1.center())};
        Zahlen down{Square(Abs(c0.radius() - c1.radius()))};
        if (dist < down) {
            return 0;
        }
        if (dist == down) {
            return 1;
        }
        Zahlen up{Square(c0.radius() + c1.radius())}; 
        if (dist < up) {
            return 2;
        }
        if (dist == up) {
            return 3;
        }
        return 4;
    }
};

} // namespace geometryZ2

} // namespace zawa
#line 2 "/home/zawatin/compro/cp-documentation/Src/Utility/BinarySearch.hpp"

#line 4 "/home/zawatin/compro/cp-documentation/Src/Utility/BinarySearch.hpp"

#include <cmath>
#include <functional>
#include <type_traits>
#include <utility>

namespace zawa {

namespace internal {

template <class T>
T MidPoint(T a, T b) {
    if (a > b) std::swap(a, b);
    return a + ((b - a) >> 1);
}

template <class T>
T Abs(T a, T b) {
    return (a >= b ? a - b : b - a);
}

} // namespace zawa::internal

template <class T, class Function>
T BinarySearch(T ok, T ng, const Function& f) {
    static_assert(std::is_integral_v<T>, "T must be integral type");
    static_assert(std::is_convertible_v<Function, std::function<bool(T)>>, "f must be function bool(T)");
    while (internal::Abs(ok, ng) > 1) {
        T mid{ internal::MidPoint(ok, ng) };
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

template <class T, class Function>
T BinarySearch(T ok, T ng, const Function& f, u32 upperLimit) {
    static_assert(std::is_signed_v<T>, "T must be signed arithmetic type");
    static_assert(std::is_convertible_v<Function, std::function<bool(T)>>, "f must be function bool(T)");
    for (u32 _{} ; _ < upperLimit ; _++) {
        T mid{ (ok + ng) / (T)2 };
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

} // namespace zawa
#line 6 "2609.test.cpp"
using namespace zawa;
using namespace geometryZ2;

int main() {
    Zahlen W, H, V, T, X, Y, P, Q;
    std::cin >> W >> H >> V >> T >> X >> Y >> P >> Q;
    Circle wave{Point{ X, Y }, V * T};
    Zahlen ans{};
    auto hito{[&](Zahlen x, Zahlen y) -> Point {
        Point res{};
        res.x() += W * x;
        if ((x % 2) ^ (x < 0)) res.x() += W - P;
        else res.x() += P;
        res.y() += H * y;
        if ((y % 2) ^ (y < 0)) res.y() += H - Q;
        else res.y() += Q;
        return res;
    }};
    auto contains{[&](Zahlen x, Zahlen y) -> bool {
        Point diff{wave.center() - hito(x, y)};
        return !diff.isNormSquareOver(wave.radiusSquare());
    }};
    for (Zahlen x{-1000000} ; x <= 1000000 ; x++) {
        if (!contains(x, 0)) continue;
        ans += BinarySearch(Zahlen{1000000}, Zahlen{0}, [&](Zahlen y) -> bool {
                return !contains(x, y);
                });
        ans += -BinarySearch(Zahlen{0}, Zahlen{-1000000}, [&](Zahlen y) -> bool {
                return contains(x, y);
                });
    }
    std::cout << ans << '\n';
}
accuracy: 0.05555555555555555
time_ms: 480
memory_kb: 3368
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
#define all(x) x.begin(), x.end()
template <class A, class B>
inline bool chmin(A& a, const B& b) {
    return b < a && (a = b, true);
}
template <class A, class B>
inline bool chmax(A& a, const B& b) {
    return b > a && (a = b, true);
}

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>

using Real = long double;
constexpr Real EPS = 1e-10;
const Real PI = std::acos(-1);

int sign(Real x) {
    return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

bool eq(Real lhs, Real rhs) {
    return sign(rhs - lhs) == 0;
}

bool lte(Real lhs, Real rhs) {
    return sign(rhs - lhs) >= 0;
}

bool lt(Real lhs, Real rhs) {
    return sign(rhs - lhs) > 0;
}

bool gte(Real lhs, Real rhs) {
    return lte(rhs, lhs);
}

bool gt(Real lhs, Real rhs) {
    return lt(rhs, lhs);
}

struct Point {
    Real x;
    Real y;
    Point(Real x = 0, Real y = 0): x(x), y(y) {}
    Point& operator+=(Point rhs) {
        this->x += rhs.x;
        this->y += rhs.y;
        return *this;
    }
    Point& operator-=(Point rhs) {
        this->x -= rhs.x;
        this->y -= rhs.y;
        return *this;
    }
    Point& operator*=(Real k) {
        this->x *= k;
        this->y *= k;
        return *this;
    }
    Point& operator/=(Real k) {
        this->x /= k;
        this->y /= k;
        return *this;
    }
    friend Point operator+(Point lhs, Point rhs) {
        return lhs += rhs;
    }
    friend Point operator-(Point lhs, Point rhs) {
        return lhs -= rhs;
    }
    friend Point operator*(Point p, Real k) {
        return p *= k;
    }
    friend Point operator/(Point p, Real k) {
        return p /= k;
    }
    friend Point operator*(Real k, Point p) {
        return p * k;
    }
    friend Point operator/(Real k, Point p) {
        return p / k;
    }
    friend bool operator==(Point lhs, Point rhs) {
        return eq(lhs.x, rhs.x) && eq(lhs.y, rhs.y);
    }
    friend bool operator!=(Point lhs, Point rhs) {
        return !(lhs == rhs);
    }
    friend bool operator<(Point lhs, Point rhs) {
        if (eq(lhs.x, rhs.x)) return lt(lhs.y, rhs.y);
        return lt(lhs.x, rhs.x);
    }
    friend bool operator<=(Point lhs, Point rhs) {
        return lhs == rhs || lhs < rhs;
    }
    friend bool operator>(Point lhs, Point rhs) {
        return rhs < lhs;
    }
    friend bool operator>=(Point lhs, Point rhs) {
        return rhs <= lhs;
    }
    friend std::istream& operator>>(std::istream& is, Point& p) {
        is >> p.x >> p.y;
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, Point& p) {
        os << p.x << ' ' << p.y;
        return os;
    }
};

using Points = std::vector<Point>;
using Polygon = Points;
using Vector = Point;

Real norm(Vector p) {
    return p.x * p.x + p.y * p.y;
}

Real abs(Vector p) {
    return std::sqrt(norm(p));
}

Real dot(Vector lhs, Vector rhs) {
    return lhs.x * rhs.x + lhs.y * rhs.y;
}

Real cross(Vector lhs, Vector rhs) {
    return lhs.x * rhs.y - lhs.y * rhs.x;
}

int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;

    if (cross(a, b) > EPS) return 1;

    if (cross(a, b) < -EPS) return -1;

    if (dot(a, b) < 0) return 2;

    if (norm(a) < norm(b)) return -2;

    return 0;
}

struct Circle {
    Real r;
    Point c;
    Circle() {}
    Circle(Real r, Point c): r(r), c(c) {}
};

struct Segment {
    Segment() {}
    Segment(Point p0, Point p1): p0(p0), p1(p1) {}
    Point p0, p1;
};

struct Line {
    Line() {}
    Line(Point p0, Point p1): p0(p0), p1(p1) {}
    explicit Line(Segment s): p0(s.p0), p1(s.p1) {}
    Point p0, p1;
};

Real distance(Point lhs, Point rhs) {
    return abs(rhs - lhs);
}

Real distance(Line l, Point p) {
    return std::abs(cross(l.p1 - l.p0, p - l.p0)) / abs(l.p1 - l.p0);
}

Real distance(Segment s, Point p) {
    if (dot(s.p1 - s.p0, p - s.p0) < 0) {
        return distance(p, s.p0);
    }
    if (dot(s.p0 - s.p1, p - s.p1) < 0) {
        return distance(p, s.p1);
    }
    return distance(Line(s), p);
}

bool intersect(Segment lhs, Segment rhs) {
    return ccw(lhs.p0, lhs.p1, rhs.p0) * ccw(lhs.p0, lhs.p1, rhs.p1) <= 0
           && ccw(rhs.p0, rhs.p1, lhs.p0) * ccw(rhs.p0, rhs.p1, lhs.p1) <= 0;
}

bool intersect(Segment s, Point p) {
    return ccw(s.p0, s.p1, p) == 0;
}

Real distance(Segment lhs, Segment rhs) {
    if (intersect(lhs, rhs)) {
        return Real(0);
    }
    return std::min({distance(lhs, rhs.p0), distance(lhs, rhs.p1), distance(rhs, lhs.p0), distance(rhs, lhs.p1)});
}

bool parallel(Vector lhs, Vector rhs) {
    return eq(cross(lhs, rhs), 0);
}

bool parallel(Segment lhs, Segment rhs) {
    return parallel(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

bool parallel(Line lhs, Line rhs) {
    return parallel(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

Point crosspoint(Line lhs, Line rhs) {
    Real a = cross(lhs.p1 - lhs.p0, rhs.p1 - rhs.p0);
    Real b = cross(lhs.p1 - lhs.p0, lhs.p1 - rhs.p0);
    return rhs.p0 + (rhs.p1 - rhs.p0) * b / a;
}

bool intersect(Line l, Segment s) {
    return ccw(l.p0, l.p1, s.p0) * ccw(l.p0, l.p1, s.p1) <= 0;
}

bool intersect(Circle c, Line l) {
    return lte(distance(l, c.c), c.r);
}

bool contain(Circle c, Point p) {
    return lt(distance(c.c, p), c.r);
}

bool intersect(Circle c, Point p) {
    return eq(distance(c.c, p), c.r);
}

bool internal(Circle c, Point p) {
    return lt(distance(c.c, p), c.r);
}

bool intersect(Circle c, Segment s) {
    return lte(distance(s, c.c), c.r);
}

int intersect(Circle lhs, Circle rhs) {
    if (gt(lhs.r, rhs.r)) std::swap(lhs, rhs);
    Real d = distance(lhs.c, rhs.c);
    if (lt(lhs.r + rhs.r, d)) return 4;
    if (eq(lhs.r + rhs.r, d)) return 3;
    if (gt(lhs.r + d, rhs.r)) return 2;
    if (eq(lhs.r + d, rhs.r)) return 1;
    return 0;
}

bool orthogonal(Vector lhs, Vector rhs) {
    return eq(dot(lhs, rhs), 0);
}

bool orthogonal(Segment lhs, Segment rhs) {
    return orthogonal(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

bool orthogonal(Line lhs, Line rhs) {
    return orthogonal(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

Point crosspoint(Segment lhs, Segment rhs) {
    Real d0 = distance(Line(lhs.p0, lhs.p1), rhs.p0);
    Real d1 = distance(Line(lhs.p0, lhs.p1), rhs.p1);
    return rhs.p0 + (rhs.p1 - rhs.p0) * (d0 / (d0 + d1));
}

Real arg(Vector p) {
    return std::atan2(p.y, p.x);
}

Vector polar(Real a, Real r) {
    return Point(std::cos(r) * a, std::sin(r) * a);
}

Point rotate(Point p, Real t) {
    Point v = polar(1, t);
    return Point(p.x * v.x - p.y * v.y, p.x * v.y + p.y * v.x);
}

Real angle(Point p0, Point p1, Point p2) {
    Real a = arg(p0 - p1);
    Real b = arg(p2 - p1);
    if (gt(a, b)) std::swap(a, b);
    return std::min(b - a, 2 * PI - (b - a));
}

Points crosspoint(Circle lhs, Circle rhs) {
    Real d = abs(lhs.c - rhs.c);
    if (eq(d, lhs.r + rhs.r)) return {lhs.c + lhs.r * (rhs.c - lhs.c) / d};
    Real a = std::acos((lhs.r * lhs.r + d * d - rhs.r * rhs.r) / (2 * lhs.r * d));
    Real t = arg(rhs.c - lhs.c);
    return {lhs.c + polar(lhs.r, t + a), lhs.c + polar(lhs.r, t - a)};
}

Point projection(Segment s, Point p) {
    Vector a = p - s.p0;
    Vector b = s.p1 - s.p0;
    Real t = dot(a, b) / norm(b);
    return s.p0 + t * b;
}

Point projection(Line l, Point p) {
    Vector a = p - l.p0;
    Vector b = l.p1 - l.p0;
    Real t = dot(a, b) / norm(b);
    return l.p0 + t * b;
}

Point reflection(Segment s, Point p) {
    return p + (projection(s, p) - p) * Real(2);
}

Point reflection(Line l, Point p) {
    return p + (projection(l, p) - p) * Real(2);
}

Points crosspoint(Circle c, Line l) {
    Vector p = projection(l, c.c);
    Real t = std::sqrt(c.r * c.r - norm(c.c - p));
    if (eq(t, 0)) return {p};
    Vector e = (l.p1 - l.p0) / abs(l.p1 - l.p0);
    return {p + t * e, p + -t * e};
}

Points crosspoint(Circle c, Segment s) {
    auto cps = crosspoint(c, Line(s));
    Points temp;
    for (auto cp: cps) {
        if (intersect(s, cp)) temp.push_back(cp);
    }
    return temp;
}

Real area(Polygon poly) {
    int n = poly.size();
    Real result = 0;
    for (int i = 0; i < n; i++) {
        result += cross(poly[i], poly[(i + 1) % n]);
    }
    return result / 2;
}

Real perimeter(Polygon poly) {
    int n = poly.size();
    Real result = 0;
    for (int i = 0; i < n; i++) {
        result += abs(poly[i] - poly[(i + 1) % n]);
    }
    return result;
}

bool convex(Polygon poly) {
    int n = poly.size();
    for (int i = 0; i < n; i++) {
        if (ccw(poly[i], poly[(i + 1) % n], poly[(i + 2) % n]) == -1) return false;
    }
    return true;
}

int contain(Polygon poly, Point p) {
    int n = poly.size();
    bool parity = false;
    for (int i = 0; i < n; i++) {
        Point a = poly[i] - p;
        Point b = poly[(i + 1) % n] - p;
        if (gt(a.y, b.y)) std::swap(a, b);
        if (lte(a.y, 0) && lt(0, b.y) && lt(cross(a, b), 0)) parity ^= true;
        if (eq(cross(a, b), 0) && lte(dot(a, b), 0)) return 1;
    }
    return (parity ? 2 : 0);
}

Polygon convex_hull(Points points) {
    std::sort(points.begin(), points.end());
    if (points.size() < 3) return points;
    int n = points.size();
    Points lower, upper;
    lower.push_back(points[n - 1]);
    lower.push_back(points[n - 2]);
    upper.push_back(points[0]);
    upper.push_back(points[1]);
    for (int i = n - 3; i >= 0; i--) {
        for (int m = lower.size(); m >= 2 && ccw(lower[m - 2], lower[m - 1], points[i]) >= 0; m--) {
            lower.pop_back();
        }
        lower.push_back(points[i]);
    }
    for (int i = 2; i < n; i++) {
        for (int m = upper.size(); m >= 2 && ccw(upper[m - 2], upper[m - 1], points[i]) >= 0; m--) {
            upper.pop_back();
        }
        upper.push_back(points[i]);
    }
    std::reverse(lower.begin(), lower.end());
    std::copy(std::next(upper.rbegin()), std::prev(upper.rend()), std::back_inserter(lower));
    return lower;
}

Polygon convex_cut(Polygon poly, Line l) {
    int n = poly.size();
    Polygon res;
    for (int i = 0; i < n; i++) {
        Point a = poly[i];
        Point b = poly[(i + 1) % n];
        if (ccw(l.p0, l.p1, a) != -1) res.push_back(a);
        if (ccw(l.p0, l.p1, a) * ccw(l.p0, l.p1, b) == -1) {
            res.push_back(crosspoint(l, Line(a, b)));
        }
    }
    return res;
}

Line bisector(Point p0, Point p1, Point p2) {
    return Line(p1, p1 + polar(1, angle(p0, p1, p2) / 2));
}

Circle incircle(Point p0, Point p1, Point p2) {
    Point c = crosspoint(bisector(p0, p1, p2), bisector(p1, p2, p0));
    Real r = std::abs(2 * area({p0, p1, p2}) / perimeter({p0, p1, p2}));
    return Circle(r, c);
}

Line perpendicular(Line l, Point p) {
    Vector v = l.p1 - l.p0;
    return Line(p, p + Vector(-v.y, v.x));
}

Line perpendicular_bisector(Segment s) {
    return perpendicular(Line(s), (s.p0 + s.p1) / 2);
}

Circle circumscribed_circle(Point p0, Point p1, Point p2) {
    Point c = crosspoint(perpendicular_bisector(Segment(p0, p1)), perpendicular_bisector(Segment(p0, p2)));
    return Circle(distance(p0, c), c);
}

Real area(Circle c) {
    return c.r * c.r * PI;
}

Points tangent(Circle c, Point p) {
    return crosspoint(c, Circle(std::sqrt(norm(c.c - p) - c.r * c.r), p));
}

bool contain(Polygon ps, Segment s) {
    if (contain(ps, s.p0) == 0 || contain(ps, s.p1) == 0) return false;
    int n = ps.size();
    Points cps;
    cps.push_back(s.p0);
    cps.push_back(s.p1);
    for (int i = 0; i < n; i++) {
        Segment t(ps[i], ps[(i + 1) % n]);
        if (parallel(s, t)) continue;
        if (!intersect(s, t)) continue;
        Point cp = crosspoint(s, t);
        if (cp != s.p0 && cp != s.p1 && cp != t.p0 && cp != t.p1) return false;
        cps.push_back(cp);
    }
    std::sort(cps.begin(), cps.end());
    int m = cps.size();
    for (int i = 0; i + 1 < m; i++) {
        if (contain(ps, (cps[i] + cps[i + 1]) / 2) == 0) return false;
    }
    return true;
}

std::pair<Points, Points> lower_and_upper_convex_hull(Polygon ps) {
    auto it = std::max_element(ps.begin(), ps.end());
    Points lower(ps.begin(), it + 1);
    Points upper(it, ps.end());
    upper.push_back(ps.front());
    std::reverse(upper.begin(), upper.end());
    return {lower, upper};
}

Real y(Line l, Real x) {
    if (eq(l.p0.x, l.p1.x)) return std::min(l.p0.y, l.p1.y);
    return x * (l.p1.y - l.p0.y) / (l.p1.x - l.p0.x);
}

Polygon common_polygon(Polygon lhs, Polygon rhs) {
    if (lhs.size() < 3 || rhs.size() < 3) return {};
    auto [ll, lu] = lower_and_upper_convex_hull(lhs);
    auto [rl, ru] = lower_and_upper_convex_hull(rhs);
    constexpr Real INF = 1e18;
    ll.push_back(Point(INF, INF));
    lu.push_back(Point(INF, INF));
    rl.push_back(Point(INF, INF));
    ru.push_back(Point(INF, INF));

    Points lower, upper;
    for (int i = 0, j = 0, k = 0, l = 0;;) {
        if (ll[i] <= lu[j] && ll[i] <= rl[k] && ll[i] <= ru[l]) {
            if (0 < k && 0 < l) {
                if (lte(y(Line(rl[k - 1], rl[k]), ll[i].x), ll[i].y)
                    && lte(ll[i].y, y(Line(ru[l - 1], ru[l]), ll[i].x))) {
                    lower.push_back(ll[i]);
                }
            }
            if (i + 2 < (int)ll.size()) {
                Segment lls(ll[i], ll[i + 1]);
                if (0 < k) {
                    Segment rls(rl[k - 1], rl[k]);
                    if (intersect(lls, rls) && !parallel(lls, rls)) {
                        lower.push_back(crosspoint(lls, rls));
                    }
                }
                if (0 < l) {
                    Segment rus(ru[l - 1], ru[l]);
                    if (intersect(lls, rus) && !parallel(lls, rus)) {
                        lower.push_back(crosspoint(lls, rus));
                        upper.push_back(crosspoint(lls, rus));
                    }
                }
            }
            i++;
            if (i + 1 == (int)ll.size() && j + 1 == (int)lu.size()) break;
        } else if (lu[j] <= ll[i] && lu[j] <= rl[k] && lu[j] <= ru[l]) {
            if (0 < k && 0 < l) {
                if (lte(y(Line(rl[k - 1], rl[k]), lu[j].x), lu[j].y)
                    && lte(lu[j].y, y(Line(ru[l - 1], ru[l]), lu[j].x))) {
                    upper.push_back(lu[j]);
                }
            }
            if (j + 2 < (int)lu.size()) {
                Segment lus(lu[j], lu[j + 1]);
                if (0 < l) {
                    Segment rus(ru[l - 1], ru[l]);
                    if (intersect(lus, rus) && !parallel(lus, rus)) {
                        upper.push_back(crosspoint(lus, rus));
                    }
                }
                if (0 < k) {
                    Segment rls(rl[k - 1], rl[k]);
                    if (intersect(lus, rls) && !parallel(lus, rls)) {
                        lower.push_back(crosspoint(lus, rls));
                        upper.push_back(crosspoint(lus, rls));
                    }
                }
            }
            j++;
            if (i + 1 == (int)ll.size() && j + 1 == (int)lu.size()) break;
        } else if (rl[k] <= ll[i] && rl[k] <= lu[j] && rl[k] <= ru[l]) {
            if (0 < i && 0 < j) {
                if (lte(y(Line(ll[i - 1], ll[i]), rl[k].x), rl[k].y)
                    && lte(rl[k].y, y(Line(lu[j - 1], lu[j]), rl[k].x))) {
                    lower.push_back(rl[k]);
                }
            }
            if (k + 2 < (int)rl.size()) {
                Segment rls(rl[k], rl[k + 1]);
                if (0 < i) {
                    Segment lls(ll[i - 1], ll[i]);
                    if (intersect(rls, lls) && !parallel(rls, lls)) {
                        lower.push_back(crosspoint(rls, lls));
                    }
                }
                if (0 < j) {
                    Segment lus(lu[j - 1], lu[j]);
                    if (intersect(rls, lus) && !parallel(rls, lus)) {
                        lower.push_back(crosspoint(rls, lus));
                        upper.push_back(crosspoint(rls, lus));
                    }
                }
            }
            k++;
            if (k + 1 == (int)rl.size() && l + 1 == (int)ru.size()) break;
        } else {
            if (0 < i && 0 < j) {
                if (lte(y(Line(ll[i - 1], ll[i]), ru[l].x), ru[l].y)
                    && lte(ru[l].y, y(Line(lu[j - 1], lu[j]), ru[l].x))) {
                    upper.push_back(ru[l]);
                }
            }
            if (l + 2 < (int)ru.size()) {
                Segment rus(ru[l], ru[l + 1]);
                if (0 < j) {
                    Segment lus(lu[j - 1], lu[j]);
                    if (intersect(rus, lus) && !parallel(rus, lus)) {
                        upper.push_back(crosspoint(rus, lus));
                    }
                }
                if (0 < i) {
                    Segment lls(ll[i - 1], ll[i]);
                    if (intersect(rus, lls) && !parallel(rus, lls)) {
                        lower.push_back(crosspoint(rus, lls));
                        upper.push_back(crosspoint(rus, lls));
                    }
                }
            }
            l++;
            if (k + 1 == (int)rl.size() && l + 1 == (int)ru.size()) break;
        }
    }
    if (lower.empty() && upper.empty()) return {};
    std::cerr << lhs.size() << ' ' << rhs.size() << ' ' << lower.size() << ' ' << upper.size() << std::endl;

    std::copy(std::next(upper.rbegin()), std::prev(upper.rend()), std::back_inserter(lower));
    return lower;
}

bool intersect(Polygon lhs, Polygon rhs) {
    return lt(0, area(common_polygon(lhs, rhs)));
}

std::vector<Line> tangent(Circle c1, Circle c2) {
    std::vector<Line> ret;
    if (c1.r < c2.r) std::swap(c1, c2);
    Real g = norm(c1.c - c2.c);
    if (eq(g, 0)) return ret;
    Point u = (c2.c - c1.c) / sqrt(g);
    Point v = rotate(u, PI * 0.5);
    for (int s: {-1, 1}) {
        Real h = (c1.r + s * c2.r) / sqrt(g);
        if (eq(1 - h * h, 0)) {
            ret.emplace_back(c1.c + u * c1.r, c1.c + (u + v) * c1.r);
        } else if (1 - h * h > 0) {
            Point uu = u * h, vv = v * sqrt(1 - h * h);
            ret.emplace_back(c1.c + (uu + vv) * c1.r, c2.c - (uu + vv) * c2.r * s);
            ret.emplace_back(c1.c + (uu - vv) * c1.r, c2.c - (uu - vv) * c2.r * s);
        }
    }
    return ret;
}

int main() {
    ll w, h, v, t, x, y, p, q;
    cin >> w >> h >> v >> t >> x >> y >> p >> q;
    Circle c(v * t, Point(x, y));
    ll INF = 1e9;

    auto sol = [&](Real r) {
        if (lte(r, 0)) return 0LL;
        ll rr = floor(r);
        ll div = rr / w;
        Real mod = r - div * w;
        if (div % 2 == 0) {
            return div + lte(p, mod);
        } else {
            return div + lte(w - p, mod);
        }
    };

    ll ans = 0;
    for (int i = 0;; i++) {
        ll hor = i * h + (i % 2 == 0 ? q : h - q);
        Line line(Point(-INF, hor), Point(INF, hor));
        if (!intersect(c, line)) break;
        auto cps = crosspoint(c, line);
        Real left = INF;
        Real right = -INF;
        for (auto cp: cps) {
            chmin(left, cp.x);
            chmax(right, cp.x);
        }
        if (lte(0, left)) {
            ans += sol(right) - sol(left - 2 * EPS);
        } else if (lte(right, 0)) {
            ans += sol(abs(left)) - sol(abs(right) - 2 * EPS);
        } else {
            ans += sol(abs(left)) + sol(abs(right));
        }
    }
    for (int i = -1;; i--) {
        ll hor = (i + 1) * h + (i % 2 != 0 ? -q : -h + q);
        Line line(Point(-INF, hor), Point(INF, hor));
        if (!intersect(c, line)) break;
        auto cps = crosspoint(c, line);
        Real left = INF;
        Real right = -INF;
        for (auto cp: cps) {
            chmin(left, cp.x);
            chmax(right, cp.x);
        }
        if (lte(0, left)) {
            ans += sol(right) - sol(left - 2 * EPS);
        } else if (lte(right, 0)) {
            ans += sol(abs(left)) - sol(abs(right) - 2 * EPS);
        } else {
            ans += sol(abs(left)) + sol(abs(right));
        }
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 50
memory_kb: 3484
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
#define all(x) x.begin(), x.end()
template <class A, class B>
inline bool chmin(A& a, const B& b) {
    return b < a && (a = b, true);
}
template <class A, class B>
inline bool chmax(A& a, const B& b) {
    return b > a && (a = b, true);
}

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>

using Real = long double;
constexpr Real EPS = 1e-10;
const Real PI = std::acos(-1);

int sign(Real x) {
    return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

bool eq(Real lhs, Real rhs) {
    return sign(rhs - lhs) == 0;
}

bool lte(Real lhs, Real rhs) {
    return sign(rhs - lhs) >= 0;
}

bool lt(Real lhs, Real rhs) {
    return sign(rhs - lhs) > 0;
}

bool gte(Real lhs, Real rhs) {
    return lte(rhs, lhs);
}

bool gt(Real lhs, Real rhs) {
    return lt(rhs, lhs);
}

struct Point {
    Real x;
    Real y;
    Point(Real x = 0, Real y = 0): x(x), y(y) {}
    Point& operator+=(Point rhs) {
        this->x += rhs.x;
        this->y += rhs.y;
        return *this;
    }
    Point& operator-=(Point rhs) {
        this->x -= rhs.x;
        this->y -= rhs.y;
        return *this;
    }
    Point& operator*=(Real k) {
        this->x *= k;
        this->y *= k;
        return *this;
    }
    Point& operator/=(Real k) {
        this->x /= k;
        this->y /= k;
        return *this;
    }
    friend Point operator+(Point lhs, Point rhs) {
        return lhs += rhs;
    }
    friend Point operator-(Point lhs, Point rhs) {
        return lhs -= rhs;
    }
    friend Point operator*(Point p, Real k) {
        return p *= k;
    }
    friend Point operator/(Point p, Real k) {
        return p /= k;
    }
    friend Point operator*(Real k, Point p) {
        return p * k;
    }
    friend Point operator/(Real k, Point p) {
        return p / k;
    }
    friend bool operator==(Point lhs, Point rhs) {
        return eq(lhs.x, rhs.x) && eq(lhs.y, rhs.y);
    }
    friend bool operator!=(Point lhs, Point rhs) {
        return !(lhs == rhs);
    }
    friend bool operator<(Point lhs, Point rhs) {
        if (eq(lhs.x, rhs.x)) return lt(lhs.y, rhs.y);
        return lt(lhs.x, rhs.x);
    }
    friend bool operator<=(Point lhs, Point rhs) {
        return lhs == rhs || lhs < rhs;
    }
    friend bool operator>(Point lhs, Point rhs) {
        return rhs < lhs;
    }
    friend bool operator>=(Point lhs, Point rhs) {
        return rhs <= lhs;
    }
    friend std::istream& operator>>(std::istream& is, Point& p) {
        is >> p.x >> p.y;
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, Point& p) {
        os << p.x << ' ' << p.y;
        return os;
    }
};

using Points = std::vector<Point>;
using Polygon = Points;
using Vector = Point;

Real norm(Vector p) {
    return p.x * p.x + p.y * p.y;
}

Real abs(Vector p) {
    return std::sqrt(norm(p));
}

Real dot(Vector lhs, Vector rhs) {
    return lhs.x * rhs.x + lhs.y * rhs.y;
}

Real cross(Vector lhs, Vector rhs) {
    return lhs.x * rhs.y - lhs.y * rhs.x;
}

int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;

    if (cross(a, b) > EPS) return 1;

    if (cross(a, b) < -EPS) return -1;

    if (dot(a, b) < 0) return 2;

    if (norm(a) < norm(b)) return -2;

    return 0;
}

struct Circle {
    Real r;
    Point c;
    Circle() {}
    Circle(Real r, Point c): r(r), c(c) {}
};

struct Segment {
    Segment() {}
    Segment(Point p0, Point p1): p0(p0), p1(p1) {}
    Point p0, p1;
};

struct Line {
    Line() {}
    Line(Point p0, Point p1): p0(p0), p1(p1) {}
    explicit Line(Segment s): p0(s.p0), p1(s.p1) {}
    Point p0, p1;
};

Real distance(Point lhs, Point rhs) {
    return abs(rhs - lhs);
}

Real distance(Line l, Point p) {
    return std::abs(cross(l.p1 - l.p0, p - l.p0)) / abs(l.p1 - l.p0);
}

Real distance(Segment s, Point p) {
    if (dot(s.p1 - s.p0, p - s.p0) < 0) {
        return distance(p, s.p0);
    }
    if (dot(s.p0 - s.p1, p - s.p1) < 0) {
        return distance(p, s.p1);
    }
    return distance(Line(s), p);
}

bool intersect(Segment lhs, Segment rhs) {
    return ccw(lhs.p0, lhs.p1, rhs.p0) * ccw(lhs.p0, lhs.p1, rhs.p1) <= 0
           && ccw(rhs.p0, rhs.p1, lhs.p0) * ccw(rhs.p0, rhs.p1, lhs.p1) <= 0;
}

bool intersect(Segment s, Point p) {
    return ccw(s.p0, s.p1, p) == 0;
}

Real distance(Segment lhs, Segment rhs) {
    if (intersect(lhs, rhs)) {
        return Real(0);
    }
    return std::min({distance(lhs, rhs.p0), distance(lhs, rhs.p1), distance(rhs, lhs.p0), distance(rhs, lhs.p1)});
}

bool parallel(Vector lhs, Vector rhs) {
    return eq(cross(lhs, rhs), 0);
}

bool parallel(Segment lhs, Segment rhs) {
    return parallel(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

bool parallel(Line lhs, Line rhs) {
    return parallel(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

Point crosspoint(Line lhs, Line rhs) {
    Real a = cross(lhs.p1 - lhs.p0, rhs.p1 - rhs.p0);
    Real b = cross(lhs.p1 - lhs.p0, lhs.p1 - rhs.p0);
    return rhs.p0 + (rhs.p1 - rhs.p0) * b / a;
}

bool intersect(Line l, Segment s) {
    return ccw(l.p0, l.p1, s.p0) * ccw(l.p0, l.p1, s.p1) <= 0;
}

bool intersect(Circle c, Line l) {
    return lte(distance(l, c.c), c.r);
}

bool contain(Circle c, Point p) {
    return lt(distance(c.c, p), c.r);
}

bool intersect(Circle c, Point p) {
    return eq(distance(c.c, p), c.r);
}

bool internal(Circle c, Point p) {
    return lt(distance(c.c, p), c.r);
}

bool intersect(Circle c, Segment s) {
    return lte(distance(s, c.c), c.r);
}

int intersect(Circle lhs, Circle rhs) {
    if (gt(lhs.r, rhs.r)) std::swap(lhs, rhs);
    Real d = distance(lhs.c, rhs.c);
    if (lt(lhs.r + rhs.r, d)) return 4;
    if (eq(lhs.r + rhs.r, d)) return 3;
    if (gt(lhs.r + d, rhs.r)) return 2;
    if (eq(lhs.r + d, rhs.r)) return 1;
    return 0;
}

bool orthogonal(Vector lhs, Vector rhs) {
    return eq(dot(lhs, rhs), 0);
}

bool orthogonal(Segment lhs, Segment rhs) {
    return orthogonal(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

bool orthogonal(Line lhs, Line rhs) {
    return orthogonal(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

Point crosspoint(Segment lhs, Segment rhs) {
    Real d0 = distance(Line(lhs.p0, lhs.p1), rhs.p0);
    Real d1 = distance(Line(lhs.p0, lhs.p1), rhs.p1);
    return rhs.p0 + (rhs.p1 - rhs.p0) * (d0 / (d0 + d1));
}

Real arg(Vector p) {
    return std::atan2(p.y, p.x);
}

Vector polar(Real a, Real r) {
    return Point(std::cos(r) * a, std::sin(r) * a);
}

Point rotate(Point p, Real t) {
    Point v = polar(1, t);
    return Point(p.x * v.x - p.y * v.y, p.x * v.y + p.y * v.x);
}

Real angle(Point p0, Point p1, Point p2) {
    Real a = arg(p0 - p1);
    Real b = arg(p2 - p1);
    if (gt(a, b)) std::swap(a, b);
    return std::min(b - a, 2 * PI - (b - a));
}

Points crosspoint(Circle lhs, Circle rhs) {
    Real d = abs(lhs.c - rhs.c);
    if (eq(d, lhs.r + rhs.r)) return {lhs.c + lhs.r * (rhs.c - lhs.c) / d};
    Real a = std::acos((lhs.r * lhs.r + d * d - rhs.r * rhs.r) / (2 * lhs.r * d));
    Real t = arg(rhs.c - lhs.c);
    return {lhs.c + polar(lhs.r, t + a), lhs.c + polar(lhs.r, t - a)};
}

Point projection(Segment s, Point p) {
    Vector a = p - s.p0;
    Vector b = s.p1 - s.p0;
    Real t = dot(a, b) / norm(b);
    return s.p0 + t * b;
}

Point projection(Line l, Point p) {
    Vector a = p - l.p0;
    Vector b = l.p1 - l.p0;
    Real t = dot(a, b) / norm(b);
    return l.p0 + t * b;
}

Point reflection(Segment s, Point p) {
    return p + (projection(s, p) - p) * Real(2);
}

Point reflection(Line l, Point p) {
    return p + (projection(l, p) - p) * Real(2);
}

Points crosspoint(Circle c, Line l) {
    Vector p = projection(l, c.c);
    Real t = std::sqrt(c.r * c.r - norm(c.c - p));
    if (eq(t, 0)) return {p};
    Vector e = (l.p1 - l.p0) / abs(l.p1 - l.p0);
    return {p + t * e, p + -t * e};
}

Points crosspoint(Circle c, Segment s) {
    auto cps = crosspoint(c, Line(s));
    Points temp;
    for (auto cp: cps) {
        if (intersect(s, cp)) temp.push_back(cp);
    }
    return temp;
}

Real area(Polygon poly) {
    int n = poly.size();
    Real result = 0;
    for (int i = 0; i < n; i++) {
        result += cross(poly[i], poly[(i + 1) % n]);
    }
    return result / 2;
}

Real perimeter(Polygon poly) {
    int n = poly.size();
    Real result = 0;
    for (int i = 0; i < n; i++) {
        result += abs(poly[i] - poly[(i + 1) % n]);
    }
    return result;
}

bool convex(Polygon poly) {
    int n = poly.size();
    for (int i = 0; i < n; i++) {
        if (ccw(poly[i], poly[(i + 1) % n], poly[(i + 2) % n]) == -1) return false;
    }
    return true;
}

int contain(Polygon poly, Point p) {
    int n = poly.size();
    bool parity = false;
    for (int i = 0; i < n; i++) {
        Point a = poly[i] - p;
        Point b = poly[(i + 1) % n] - p;
        if (gt(a.y, b.y)) std::swap(a, b);
        if (lte(a.y, 0) && lt(0, b.y) && lt(cross(a, b), 0)) parity ^= true;
        if (eq(cross(a, b), 0) && lte(dot(a, b), 0)) return 1;
    }
    return (parity ? 2 : 0);
}

Polygon convex_hull(Points points) {
    std::sort(points.begin(), points.end());
    if (points.size() < 3) return points;
    int n = points.size();
    Points lower, upper;
    lower.push_back(points[n - 1]);
    lower.push_back(points[n - 2]);
    upper.push_back(points[0]);
    upper.push_back(points[1]);
    for (int i = n - 3; i >= 0; i--) {
        for (int m = lower.size(); m >= 2 && ccw(lower[m - 2], lower[m - 1], points[i]) >= 0; m--) {
            lower.pop_back();
        }
        lower.push_back(points[i]);
    }
    for (int i = 2; i < n; i++) {
        for (int m = upper.size(); m >= 2 && ccw(upper[m - 2], upper[m - 1], points[i]) >= 0; m--) {
            upper.pop_back();
        }
        upper.push_back(points[i]);
    }
    std::reverse(lower.begin(), lower.end());
    std::copy(std::next(upper.rbegin()), std::prev(upper.rend()), std::back_inserter(lower));
    return lower;
}

Polygon convex_cut(Polygon poly, Line l) {
    int n = poly.size();
    Polygon res;
    for (int i = 0; i < n; i++) {
        Point a = poly[i];
        Point b = poly[(i + 1) % n];
        if (ccw(l.p0, l.p1, a) != -1) res.push_back(a);
        if (ccw(l.p0, l.p1, a) * ccw(l.p0, l.p1, b) == -1) {
            res.push_back(crosspoint(l, Line(a, b)));
        }
    }
    return res;
}

Line bisector(Point p0, Point p1, Point p2) {
    return Line(p1, p1 + polar(1, angle(p0, p1, p2) / 2));
}

Circle incircle(Point p0, Point p1, Point p2) {
    Point c = crosspoint(bisector(p0, p1, p2), bisector(p1, p2, p0));
    Real r = std::abs(2 * area({p0, p1, p2}) / perimeter({p0, p1, p2}));
    return Circle(r, c);
}

Line perpendicular(Line l, Point p) {
    Vector v = l.p1 - l.p0;
    return Line(p, p + Vector(-v.y, v.x));
}

Line perpendicular_bisector(Segment s) {
    return perpendicular(Line(s), (s.p0 + s.p1) / 2);
}

Circle circumscribed_circle(Point p0, Point p1, Point p2) {
    Point c = crosspoint(perpendicular_bisector(Segment(p0, p1)), perpendicular_bisector(Segment(p0, p2)));
    return Circle(distance(p0, c), c);
}

Real area(Circle c) {
    return c.r * c.r * PI;
}

Points tangent(Circle c, Point p) {
    return crosspoint(c, Circle(std::sqrt(norm(c.c - p) - c.r * c.r), p));
}

bool contain(Polygon ps, Segment s) {
    if (contain(ps, s.p0) == 0 || contain(ps, s.p1) == 0) return false;
    int n = ps.size();
    Points cps;
    cps.push_back(s.p0);
    cps.push_back(s.p1);
    for (int i = 0; i < n; i++) {
        Segment t(ps[i], ps[(i + 1) % n]);
        if (parallel(s, t)) continue;
        if (!intersect(s, t)) continue;
        Point cp = crosspoint(s, t);
        if (cp != s.p0 && cp != s.p1 && cp != t.p0 && cp != t.p1) return false;
        cps.push_back(cp);
    }
    std::sort(cps.begin(), cps.end());
    int m = cps.size();
    for (int i = 0; i + 1 < m; i++) {
        if (contain(ps, (cps[i] + cps[i + 1]) / 2) == 0) return false;
    }
    return true;
}

std::pair<Points, Points> lower_and_upper_convex_hull(Polygon ps) {
    auto it = std::max_element(ps.begin(), ps.end());
    Points lower(ps.begin(), it + 1);
    Points upper(it, ps.end());
    upper.push_back(ps.front());
    std::reverse(upper.begin(), upper.end());
    return {lower, upper};
}

Real y(Line l, Real x) {
    if (eq(l.p0.x, l.p1.x)) return std::min(l.p0.y, l.p1.y);
    return x * (l.p1.y - l.p0.y) / (l.p1.x - l.p0.x);
}

Polygon common_polygon(Polygon lhs, Polygon rhs) {
    if (lhs.size() < 3 || rhs.size() < 3) return {};
    auto [ll, lu] = lower_and_upper_convex_hull(lhs);
    auto [rl, ru] = lower_and_upper_convex_hull(rhs);
    constexpr Real INF = 1e18;
    ll.push_back(Point(INF, INF));
    lu.push_back(Point(INF, INF));
    rl.push_back(Point(INF, INF));
    ru.push_back(Point(INF, INF));

    Points lower, upper;
    for (int i = 0, j = 0, k = 0, l = 0;;) {
        if (ll[i] <= lu[j] && ll[i] <= rl[k] && ll[i] <= ru[l]) {
            if (0 < k && 0 < l) {
                if (lte(y(Line(rl[k - 1], rl[k]), ll[i].x), ll[i].y)
                    && lte(ll[i].y, y(Line(ru[l - 1], ru[l]), ll[i].x))) {
                    lower.push_back(ll[i]);
                }
            }
            if (i + 2 < (int)ll.size()) {
                Segment lls(ll[i], ll[i + 1]);
                if (0 < k) {
                    Segment rls(rl[k - 1], rl[k]);
                    if (intersect(lls, rls) && !parallel(lls, rls)) {
                        lower.push_back(crosspoint(lls, rls));
                    }
                }
                if (0 < l) {
                    Segment rus(ru[l - 1], ru[l]);
                    if (intersect(lls, rus) && !parallel(lls, rus)) {
                        lower.push_back(crosspoint(lls, rus));
                        upper.push_back(crosspoint(lls, rus));
                    }
                }
            }
            i++;
            if (i + 1 == (int)ll.size() && j + 1 == (int)lu.size()) break;
        } else if (lu[j] <= ll[i] && lu[j] <= rl[k] && lu[j] <= ru[l]) {
            if (0 < k && 0 < l) {
                if (lte(y(Line(rl[k - 1], rl[k]), lu[j].x), lu[j].y)
                    && lte(lu[j].y, y(Line(ru[l - 1], ru[l]), lu[j].x))) {
                    upper.push_back(lu[j]);
                }
            }
            if (j + 2 < (int)lu.size()) {
                Segment lus(lu[j], lu[j + 1]);
                if (0 < l) {
                    Segment rus(ru[l - 1], ru[l]);
                    if (intersect(lus, rus) && !parallel(lus, rus)) {
                        upper.push_back(crosspoint(lus, rus));
                    }
                }
                if (0 < k) {
                    Segment rls(rl[k - 1], rl[k]);
                    if (intersect(lus, rls) && !parallel(lus, rls)) {
                        lower.push_back(crosspoint(lus, rls));
                        upper.push_back(crosspoint(lus, rls));
                    }
                }
            }
            j++;
            if (i + 1 == (int)ll.size() && j + 1 == (int)lu.size()) break;
        } else if (rl[k] <= ll[i] && rl[k] <= lu[j] && rl[k] <= ru[l]) {
            if (0 < i && 0 < j) {
                if (lte(y(Line(ll[i - 1], ll[i]), rl[k].x), rl[k].y)
                    && lte(rl[k].y, y(Line(lu[j - 1], lu[j]), rl[k].x))) {
                    lower.push_back(rl[k]);
                }
            }
            if (k + 2 < (int)rl.size()) {
                Segment rls(rl[k], rl[k + 1]);
                if (0 < i) {
                    Segment lls(ll[i - 1], ll[i]);
                    if (intersect(rls, lls) && !parallel(rls, lls)) {
                        lower.push_back(crosspoint(rls, lls));
                    }
                }
                if (0 < j) {
                    Segment lus(lu[j - 1], lu[j]);
                    if (intersect(rls, lus) && !parallel(rls, lus)) {
                        lower.push_back(crosspoint(rls, lus));
                        upper.push_back(crosspoint(rls, lus));
                    }
                }
            }
            k++;
            if (k + 1 == (int)rl.size() && l + 1 == (int)ru.size()) break;
        } else {
            if (0 < i && 0 < j) {
                if (lte(y(Line(ll[i - 1], ll[i]), ru[l].x), ru[l].y)
                    && lte(ru[l].y, y(Line(lu[j - 1], lu[j]), ru[l].x))) {
                    upper.push_back(ru[l]);
                }
            }
            if (l + 2 < (int)ru.size()) {
                Segment rus(ru[l], ru[l + 1]);
                if (0 < j) {
                    Segment lus(lu[j - 1], lu[j]);
                    if (intersect(rus, lus) && !parallel(rus, lus)) {
                        upper.push_back(crosspoint(rus, lus));
                    }
                }
                if (0 < i) {
                    Segment lls(ll[i - 1], ll[i]);
                    if (intersect(rus, lls) && !parallel(rus, lls)) {
                        lower.push_back(crosspoint(rus, lls));
                        upper.push_back(crosspoint(rus, lls));
                    }
                }
            }
            l++;
            if (k + 1 == (int)rl.size() && l + 1 == (int)ru.size()) break;
        }
    }
    if (lower.empty() && upper.empty()) return {};
    std::cerr << lhs.size() << ' ' << rhs.size() << ' ' << lower.size() << ' ' << upper.size() << std::endl;

    std::copy(std::next(upper.rbegin()), std::prev(upper.rend()), std::back_inserter(lower));
    return lower;
}

bool intersect(Polygon lhs, Polygon rhs) {
    return lt(0, area(common_polygon(lhs, rhs)));
}

std::vector<Line> tangent(Circle c1, Circle c2) {
    std::vector<Line> ret;
    if (c1.r < c2.r) std::swap(c1, c2);
    Real g = norm(c1.c - c2.c);
    if (eq(g, 0)) return ret;
    Point u = (c2.c - c1.c) / sqrt(g);
    Point v = rotate(u, PI * 0.5);
    for (int s: {-1, 1}) {
        Real h = (c1.r + s * c2.r) / sqrt(g);
        if (eq(1 - h * h, 0)) {
            ret.emplace_back(c1.c + u * c1.r, c1.c + (u + v) * c1.r);
        } else if (1 - h * h > 0) {
            Point uu = u * h, vv = v * sqrt(1 - h * h);
            ret.emplace_back(c1.c + (uu + vv) * c1.r, c2.c - (uu + vv) * c2.r * s);
            ret.emplace_back(c1.c + (uu - vv) * c1.r, c2.c - (uu - vv) * c2.r * s);
        }
    }
    return ret;
}

int main() {
    ll w, h, v, t, x, y, p, q;
    cin >> w >> h >> v >> t >> x >> y >> p >> q;
    Circle c(v * t, Point(x, y));
    ll INF = 1e9;

    auto sol = [&](Real r) {
        ll rr = floor(r);
        ll div = rr / w;
        Real mod = r - div * w;
        if (div % 2 == 0) {
            return div + lte(p, mod);
        } else {
            return div + lte(w - p, mod);
        }
    };

    ll ans = 0;
    for (int i = 0;; i++) {
        ll hor = i * h + (i % 2 == 0 ? q : h - q);
        Line line(Point(-INF, hor), Point(INF, hor));
        if (!intersect(c, line)) break;
        auto cps = crosspoint(c, line);
        Real left = INF;
        Real right = -INF;
        for (auto cp: cps) {
            chmin(left, cp.x);
            chmax(right, cp.x);
        }
        if (lte(0, left)) {
            ans += sol(right) - sol(left - EPS);
        } else if (lte(right, 0)) {
            ans += sol(abs(left)) - sol(abs(right) - EPS);
        } else {
            ans += sol(abs(left)) + sol(abs(right));
        }
    }
    for (int i = -1;; i--) {
        ll hor = (i + 1) * h + (i % 2 != 0 ? -q : -h + q);
        Line line(Point(-INF, hor), Point(INF, hor));
        if (!intersect(c, line)) break;
        auto cps = crosspoint(c, line);
        Real left = INF;
        Real right = -INF;
        for (auto cp: cps) {
            chmin(left, cp.x);
            chmax(right, cp.x);
        }
        if (lte(0, left)) {
            ans += sol(right) - sol(left - EPS);
        } else if (lte(right, 0)) {
            ans += sol(abs(left)) - sol(abs(right) - EPS);
        } else {
            ans += sol(abs(left)) + sol(abs(right));
        }
    }
    cout << ans << endl;
}
accuracy: 0.9444444444444444
time_ms: 50
memory_kb: 3484
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
#define all(x) x.begin(), x.end()
template <class A, class B>
inline bool chmin(A& a, const B& b) {
    return b < a && (a = b, true);
}
template <class A, class B>
inline bool chmax(A& a, const B& b) {
    return b > a && (a = b, true);
}

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>

using Real = long double;
constexpr Real EPS = 1e-10;
const Real PI = std::acos(-1);

int sign(Real x) {
    return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

bool eq(Real lhs, Real rhs) {
    return sign(rhs - lhs) == 0;
}

bool lte(Real lhs, Real rhs) {
    return sign(rhs - lhs) >= 0;
}

bool lt(Real lhs, Real rhs) {
    return sign(rhs - lhs) > 0;
}

bool gte(Real lhs, Real rhs) {
    return lte(rhs, lhs);
}

bool gt(Real lhs, Real rhs) {
    return lt(rhs, lhs);
}

struct Point {
    Real x;
    Real y;
    Point(Real x = 0, Real y = 0): x(x), y(y) {}
    Point& operator+=(Point rhs) {
        this->x += rhs.x;
        this->y += rhs.y;
        return *this;
    }
    Point& operator-=(Point rhs) {
        this->x -= rhs.x;
        this->y -= rhs.y;
        return *this;
    }
    Point& operator*=(Real k) {
        this->x *= k;
        this->y *= k;
        return *this;
    }
    Point& operator/=(Real k) {
        this->x /= k;
        this->y /= k;
        return *this;
    }
    friend Point operator+(Point lhs, Point rhs) {
        return lhs += rhs;
    }
    friend Point operator-(Point lhs, Point rhs) {
        return lhs -= rhs;
    }
    friend Point operator*(Point p, Real k) {
        return p *= k;
    }
    friend Point operator/(Point p, Real k) {
        return p /= k;
    }
    friend Point operator*(Real k, Point p) {
        return p * k;
    }
    friend Point operator/(Real k, Point p) {
        return p / k;
    }
    friend bool operator==(Point lhs, Point rhs) {
        return eq(lhs.x, rhs.x) && eq(lhs.y, rhs.y);
    }
    friend bool operator!=(Point lhs, Point rhs) {
        return !(lhs == rhs);
    }
    friend bool operator<(Point lhs, Point rhs) {
        if (eq(lhs.x, rhs.x)) return lt(lhs.y, rhs.y);
        return lt(lhs.x, rhs.x);
    }
    friend bool operator<=(Point lhs, Point rhs) {
        return lhs == rhs || lhs < rhs;
    }
    friend bool operator>(Point lhs, Point rhs) {
        return rhs < lhs;
    }
    friend bool operator>=(Point lhs, Point rhs) {
        return rhs <= lhs;
    }
    friend std::istream& operator>>(std::istream& is, Point& p) {
        is >> p.x >> p.y;
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, Point& p) {
        os << p.x << ' ' << p.y;
        return os;
    }
};

using Points = std::vector<Point>;
using Polygon = Points;
using Vector = Point;

Real norm(Vector p) {
    return p.x * p.x + p.y * p.y;
}

Real abs(Vector p) {
    return std::sqrt(norm(p));
}

Real dot(Vector lhs, Vector rhs) {
    return lhs.x * rhs.x + lhs.y * rhs.y;
}

Real cross(Vector lhs, Vector rhs) {
    return lhs.x * rhs.y - lhs.y * rhs.x;
}

int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;

    if (cross(a, b) > EPS) return 1;

    if (cross(a, b) < -EPS) return -1;

    if (dot(a, b) < 0) return 2;

    if (norm(a) < norm(b)) return -2;

    return 0;
}

struct Circle {
    Real r;
    Point c;
    Circle() {}
    Circle(Real r, Point c): r(r), c(c) {}
};

struct Segment {
    Segment() {}
    Segment(Point p0, Point p1): p0(p0), p1(p1) {}
    Point p0, p1;
};

struct Line {
    Line() {}
    Line(Point p0, Point p1): p0(p0), p1(p1) {}
    explicit Line(Segment s): p0(s.p0), p1(s.p1) {}
    Point p0, p1;
};

Real distance(Point lhs, Point rhs) {
    return abs(rhs - lhs);
}

Real distance(Line l, Point p) {
    return std::abs(cross(l.p1 - l.p0, p - l.p0)) / abs(l.p1 - l.p0);
}

Real distance(Segment s, Point p) {
    if (dot(s.p1 - s.p0, p - s.p0) < 0) {
        return distance(p, s.p0);
    }
    if (dot(s.p0 - s.p1, p - s.p1) < 0) {
        return distance(p, s.p1);
    }
    return distance(Line(s), p);
}

bool intersect(Segment lhs, Segment rhs) {
    return ccw(lhs.p0, lhs.p1, rhs.p0) * ccw(lhs.p0, lhs.p1, rhs.p1) <= 0
           && ccw(rhs.p0, rhs.p1, lhs.p0) * ccw(rhs.p0, rhs.p1, lhs.p1) <= 0;
}

bool intersect(Segment s, Point p) {
    return ccw(s.p0, s.p1, p) == 0;
}

Real distance(Segment lhs, Segment rhs) {
    if (intersect(lhs, rhs)) {
        return Real(0);
    }
    return std::min({distance(lhs, rhs.p0), distance(lhs, rhs.p1), distance(rhs, lhs.p0), distance(rhs, lhs.p1)});
}

bool parallel(Vector lhs, Vector rhs) {
    return eq(cross(lhs, rhs), 0);
}

bool parallel(Segment lhs, Segment rhs) {
    return parallel(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

bool parallel(Line lhs, Line rhs) {
    return parallel(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

Point crosspoint(Line lhs, Line rhs) {
    Real a = cross(lhs.p1 - lhs.p0, rhs.p1 - rhs.p0);
    Real b = cross(lhs.p1 - lhs.p0, lhs.p1 - rhs.p0);
    return rhs.p0 + (rhs.p1 - rhs.p0) * b / a;
}

bool intersect(Line l, Segment s) {
    return ccw(l.p0, l.p1, s.p0) * ccw(l.p0, l.p1, s.p1) <= 0;
}

bool intersect(Circle c, Line l) {
    return lte(distance(l, c.c), c.r);
}

bool contain(Circle c, Point p) {
    return lt(distance(c.c, p), c.r);
}

bool intersect(Circle c, Point p) {
    return eq(distance(c.c, p), c.r);
}

bool internal(Circle c, Point p) {
    return lt(distance(c.c, p), c.r);
}

bool intersect(Circle c, Segment s) {
    return lte(distance(s, c.c), c.r);
}

int intersect(Circle lhs, Circle rhs) {
    if (gt(lhs.r, rhs.r)) std::swap(lhs, rhs);
    Real d = distance(lhs.c, rhs.c);
    if (lt(lhs.r + rhs.r, d)) return 4;
    if (eq(lhs.r + rhs.r, d)) return 3;
    if (gt(lhs.r + d, rhs.r)) return 2;
    if (eq(lhs.r + d, rhs.r)) return 1;
    return 0;
}

bool orthogonal(Vector lhs, Vector rhs) {
    return eq(dot(lhs, rhs), 0);
}

bool orthogonal(Segment lhs, Segment rhs) {
    return orthogonal(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

bool orthogonal(Line lhs, Line rhs) {
    return orthogonal(lhs.p0 - lhs.p1, rhs.p0 - rhs.p1);
}

Point crosspoint(Segment lhs, Segment rhs) {
    Real d0 = distance(Line(lhs.p0, lhs.p1), rhs.p0);
    Real d1 = distance(Line(lhs.p0, lhs.p1), rhs.p1);
    return rhs.p0 + (rhs.p1 - rhs.p0) * (d0 / (d0 + d1));
}

Real arg(Vector p) {
    return std::atan2(p.y, p.x);
}

Vector polar(Real a, Real r) {
    return Point(std::cos(r) * a, std::sin(r) * a);
}

Point rotate(Point p, Real t) {
    Point v = polar(1, t);
    return Point(p.x * v.x - p.y * v.y, p.x * v.y + p.y * v.x);
}

Real angle(Point p0, Point p1, Point p2) {
    Real a = arg(p0 - p1);
    Real b = arg(p2 - p1);
    if (gt(a, b)) std::swap(a, b);
    return std::min(b - a, 2 * PI - (b - a));
}

Points crosspoint(Circle lhs, Circle rhs) {
    Real d = abs(lhs.c - rhs.c);
    if (eq(d, lhs.r + rhs.r)) return {lhs.c + lhs.r * (rhs.c - lhs.c) / d};
    Real a = std::acos((lhs.r * lhs.r + d * d - rhs.r * rhs.r) / (2 * lhs.r * d));
    Real t = arg(rhs.c - lhs.c);
    return {lhs.c + polar(lhs.r, t + a), lhs.c + polar(lhs.r, t - a)};
}

Point projection(Segment s, Point p) {
    Vector a = p - s.p0;
    Vector b = s.p1 - s.p0;
    Real t = dot(a, b) / norm(b);
    return s.p0 + t * b;
}

Point projection(Line l, Point p) {
    Vector a = p - l.p0;
    Vector b = l.p1 - l.p0;
    Real t = dot(a, b) / norm(b);
    return l.p0 + t * b;
}

Point reflection(Segment s, Point p) {
    return p + (projection(s, p) - p) * Real(2);
}

Point reflection(Line l, Point p) {
    return p + (projection(l, p) - p) * Real(2);
}

Points crosspoint(Circle c, Line l) {
    Vector p = projection(l, c.c);
    Real t = std::sqrt(c.r * c.r - norm(c.c - p));
    if (eq(t, 0)) return {p};
    Vector e = (l.p1 - l.p0) / abs(l.p1 - l.p0);
    return {p + t * e, p + -t * e};
}

Points crosspoint(Circle c, Segment s) {
    auto cps = crosspoint(c, Line(s));
    Points temp;
    for (auto cp: cps) {
        if (intersect(s, cp)) temp.push_back(cp);
    }
    return temp;
}

Real area(Polygon poly) {
    int n = poly.size();
    Real result = 0;
    for (int i = 0; i < n; i++) {
        result += cross(poly[i], poly[(i + 1) % n]);
    }
    return result / 2;
}

Real perimeter(Polygon poly) {
    int n = poly.size();
    Real result = 0;
    for (int i = 0; i < n; i++) {
        result += abs(poly[i] - poly[(i + 1) % n]);
    }
    return result;
}

bool convex(Polygon poly) {
    int n = poly.size();
    for (int i = 0; i < n; i++) {
        if (ccw(poly[i], poly[(i + 1) % n], poly[(i + 2) % n]) == -1) return false;
    }
    return true;
}

int contain(Polygon poly, Point p) {
    int n = poly.size();
    bool parity = false;
    for (int i = 0; i < n; i++) {
        Point a = poly[i] - p;
        Point b = poly[(i + 1) % n] - p;
        if (gt(a.y, b.y)) std::swap(a, b);
        if (lte(a.y, 0) && lt(0, b.y) && lt(cross(a, b), 0)) parity ^= true;
        if (eq(cross(a, b), 0) && lte(dot(a, b), 0)) return 1;
    }
    return (parity ? 2 : 0);
}

Polygon convex_hull(Points points) {
    std::sort(points.begin(), points.end());
    if (points.size() < 3) return points;
    int n = points.size();
    Points lower, upper;
    lower.push_back(points[n - 1]);
    lower.push_back(points[n - 2]);
    upper.push_back(points[0]);
    upper.push_back(points[1]);
    for (int i = n - 3; i >= 0; i--) {
        for (int m = lower.size(); m >= 2 && ccw(lower[m - 2], lower[m - 1], points[i]) >= 0; m--) {
            lower.pop_back();
        }
        lower.push_back(points[i]);
    }
    for (int i = 2; i < n; i++) {
        for (int m = upper.size(); m >= 2 && ccw(upper[m - 2], upper[m - 1], points[i]) >= 0; m--) {
            upper.pop_back();
        }
        upper.push_back(points[i]);
    }
    std::reverse(lower.begin(), lower.end());
    std::copy(std::next(upper.rbegin()), std::prev(upper.rend()), std::back_inserter(lower));
    return lower;
}

Polygon convex_cut(Polygon poly, Line l) {
    int n = poly.size();
    Polygon res;
    for (int i = 0; i < n; i++) {
        Point a = poly[i];
        Point b = poly[(i + 1) % n];
        if (ccw(l.p0, l.p1, a) != -1) res.push_back(a);
        if (ccw(l.p0, l.p1, a) * ccw(l.p0, l.p1, b) == -1) {
            res.push_back(crosspoint(l, Line(a, b)));
        }
    }
    return res;
}

Line bisector(Point p0, Point p1, Point p2) {
    return Line(p1, p1 + polar(1, angle(p0, p1, p2) / 2));
}

Circle incircle(Point p0, Point p1, Point p2) {
    Point c = crosspoint(bisector(p0, p1, p2), bisector(p1, p2, p0));
    Real r = std::abs(2 * area({p0, p1, p2}) / perimeter({p0, p1, p2}));
    return Circle(r, c);
}

Line perpendicular(Line l, Point p) {
    Vector v = l.p1 - l.p0;
    return Line(p, p + Vector(-v.y, v.x));
}

Line perpendicular_bisector(Segment s) {
    return perpendicular(Line(s), (s.p0 + s.p1) / 2);
}

Circle circumscribed_circle(Point p0, Point p1, Point p2) {
    Point c = crosspoint(perpendicular_bisector(Segment(p0, p1)), perpendicular_bisector(Segment(p0, p2)));
    return Circle(distance(p0, c), c);
}

Real area(Circle c) {
    return c.r * c.r * PI;
}

Points tangent(Circle c, Point p) {
    return crosspoint(c, Circle(std::sqrt(norm(c.c - p) - c.r * c.r), p));
}

bool contain(Polygon ps, Segment s) {
    if (contain(ps, s.p0) == 0 || contain(ps, s.p1) == 0) return false;
    int n = ps.size();
    Points cps;
    cps.push_back(s.p0);
    cps.push_back(s.p1);
    for (int i = 0; i < n; i++) {
        Segment t(ps[i], ps[(i + 1) % n]);
        if (parallel(s, t)) continue;
        if (!intersect(s, t)) continue;
        Point cp = crosspoint(s, t);
        if (cp != s.p0 && cp != s.p1 && cp != t.p0 && cp != t.p1) return false;
        cps.push_back(cp);
    }
    std::sort(cps.begin(), cps.end());
    int m = cps.size();
    for (int i = 0; i + 1 < m; i++) {
        if (contain(ps, (cps[i] + cps[i + 1]) / 2) == 0) return false;
    }
    return true;
}

std::pair<Points, Points> lower_and_upper_convex_hull(Polygon ps) {
    auto it = std::max_element(ps.begin(), ps.end());
    Points lower(ps.begin(), it + 1);
    Points upper(it, ps.end());
    upper.push_back(ps.front());
    std::reverse(upper.begin(), upper.end());
    return {lower, upper};
}

Real y(Line l, Real x) {
    if (eq(l.p0.x, l.p1.x)) return std::min(l.p0.y, l.p1.y);
    return x * (l.p1.y - l.p0.y) / (l.p1.x - l.p0.x);
}

Polygon common_polygon(Polygon lhs, Polygon rhs) {
    if (lhs.size() < 3 || rhs.size() < 3) return {};
    auto [ll, lu] = lower_and_upper_convex_hull(lhs);
    auto [rl, ru] = lower_and_upper_convex_hull(rhs);
    constexpr Real INF = 1e18;
    ll.push_back(Point(INF, INF));
    lu.push_back(Point(INF, INF));
    rl.push_back(Point(INF, INF));
    ru.push_back(Point(INF, INF));

    Points lower, upper;
    for (int i = 0, j = 0, k = 0, l = 0;;) {
        if (ll[i] <= lu[j] && ll[i] <= rl[k] && ll[i] <= ru[l]) {
            if (0 < k && 0 < l) {
                if (lte(y(Line(rl[k - 1], rl[k]), ll[i].x), ll[i].y)
                    && lte(ll[i].y, y(Line(ru[l - 1], ru[l]), ll[i].x))) {
                    lower.push_back(ll[i]);
                }
            }
            if (i + 2 < (int)ll.size()) {
                Segment lls(ll[i], ll[i + 1]);
                if (0 < k) {
                    Segment rls(rl[k - 1], rl[k]);
                    if (intersect(lls, rls) && !parallel(lls, rls)) {
                        lower.push_back(crosspoint(lls, rls));
                    }
                }
                if (0 < l) {
                    Segment rus(ru[l - 1], ru[l]);
                    if (intersect(lls, rus) && !parallel(lls, rus)) {
                        lower.push_back(crosspoint(lls, rus));
                        upper.push_back(crosspoint(lls, rus));
                    }
                }
            }
            i++;
            if (i + 1 == (int)ll.size() && j + 1 == (int)lu.size()) break;
        } else if (lu[j] <= ll[i] && lu[j] <= rl[k] && lu[j] <= ru[l]) {
            if (0 < k && 0 < l) {
                if (lte(y(Line(rl[k - 1], rl[k]), lu[j].x), lu[j].y)
                    && lte(lu[j].y, y(Line(ru[l - 1], ru[l]), lu[j].x))) {
                    upper.push_back(lu[j]);
                }
            }
            if (j + 2 < (int)lu.size()) {
                Segment lus(lu[j], lu[j + 1]);
                if (0 < l) {
                    Segment rus(ru[l - 1], ru[l]);
                    if (intersect(lus, rus) && !parallel(lus, rus)) {
                        upper.push_back(crosspoint(lus, rus));
                    }
                }
                if (0 < k) {
                    Segment rls(rl[k - 1], rl[k]);
                    if (intersect(lus, rls) && !parallel(lus, rls)) {
                        lower.push_back(crosspoint(lus, rls));
                        upper.push_back(crosspoint(lus, rls));
                    }
                }
            }
            j++;
            if (i + 1 == (int)ll.size() && j + 1 == (int)lu.size()) break;
        } else if (rl[k] <= ll[i] && rl[k] <= lu[j] && rl[k] <= ru[l]) {
            if (0 < i && 0 < j) {
                if (lte(y(Line(ll[i - 1], ll[i]), rl[k].x), rl[k].y)
                    && lte(rl[k].y, y(Line(lu[j - 1], lu[j]), rl[k].x))) {
                    lower.push_back(rl[k]);
                }
            }
            if (k + 2 < (int)rl.size()) {
                Segment rls(rl[k], rl[k + 1]);
                if (0 < i) {
                    Segment lls(ll[i - 1], ll[i]);
                    if (intersect(rls, lls) && !parallel(rls, lls)) {
                        lower.push_back(crosspoint(rls, lls));
                    }
                }
                if (0 < j) {
                    Segment lus(lu[j - 1], lu[j]);
                    if (intersect(rls, lus) && !parallel(rls, lus)) {
                        lower.push_back(crosspoint(rls, lus));
                        upper.push_back(crosspoint(rls, lus));
                    }
                }
            }
            k++;
            if (k + 1 == (int)rl.size() && l + 1 == (int)ru.size()) break;
        } else {
            if (0 < i && 0 < j) {
                if (lte(y(Line(ll[i - 1], ll[i]), ru[l].x), ru[l].y)
                    && lte(ru[l].y, y(Line(lu[j - 1], lu[j]), ru[l].x))) {
                    upper.push_back(ru[l]);
                }
            }
            if (l + 2 < (int)ru.size()) {
                Segment rus(ru[l], ru[l + 1]);
                if (0 < j) {
                    Segment lus(lu[j - 1], lu[j]);
                    if (intersect(rus, lus) && !parallel(rus, lus)) {
                        upper.push_back(crosspoint(rus, lus));
                    }
                }
                if (0 < i) {
                    Segment lls(ll[i - 1], ll[i]);
                    if (intersect(rus, lls) && !parallel(rus, lls)) {
                        lower.push_back(crosspoint(rus, lls));
                        upper.push_back(crosspoint(rus, lls));
                    }
                }
            }
            l++;
            if (k + 1 == (int)rl.size() && l + 1 == (int)ru.size()) break;
        }
    }
    if (lower.empty() && upper.empty()) return {};
    std::cerr << lhs.size() << ' ' << rhs.size() << ' ' << lower.size() << ' ' << upper.size() << std::endl;

    std::copy(std::next(upper.rbegin()), std::prev(upper.rend()), std::back_inserter(lower));
    return lower;
}

bool intersect(Polygon lhs, Polygon rhs) {
    return lt(0, area(common_polygon(lhs, rhs)));
}

std::vector<Line> tangent(Circle c1, Circle c2) {
    std::vector<Line> ret;
    if (c1.r < c2.r) std::swap(c1, c2);
    Real g = norm(c1.c - c2.c);
    if (eq(g, 0)) return ret;
    Point u = (c2.c - c1.c) / sqrt(g);
    Point v = rotate(u, PI * 0.5);
    for (int s: {-1, 1}) {
        Real h = (c1.r + s * c2.r) / sqrt(g);
        if (eq(1 - h * h, 0)) {
            ret.emplace_back(c1.c + u * c1.r, c1.c + (u + v) * c1.r);
        } else if (1 - h * h > 0) {
            Point uu = u * h, vv = v * sqrt(1 - h * h);
            ret.emplace_back(c1.c + (uu + vv) * c1.r, c2.c - (uu + vv) * c2.r * s);
            ret.emplace_back(c1.c + (uu - vv) * c1.r, c2.c - (uu - vv) * c2.r * s);
        }
    }
    return ret;
}

int main() {
    ll w, h, v, t, x, y, p, q;
    cin >> w >> h >> v >> t >> x >> y >> p >> q;
    Circle c(v * t, Point(y, x));
    ll INF = 1e9;

    auto sol = [&](Real r) {
        ll rr = floor(r);
        ll div = rr / w;
        Real mod = r - div * w;
        if (div % 2 == 0) {
            return div + lte(p, mod);
        } else {
            return div + lte(w - p, mod);
        }
    };

    ll ans = 0;
    for (int i = 0;; i++) {
        ll hor = i * h + (i % 2 == 0 ? q : h - q);
        Line line(Point(-INF, hor), Point(INF, hor));
        if (!intersect(c, line)) break;
        auto cps = crosspoint(c, line);
        Real left = INF;
        Real right = -INF;
        for (auto cp: cps) {
            chmin(left, cp.x);
            chmax(right, cp.x);
        }
        if (lte(0, left)) {
            ans += sol(right) - sol(left - EPS);
        } else if (lte(right, 0)) {
            ans += sol(abs(left)) - sol(abs(right) - EPS);
        } else {
            ans += sol(abs(left)) + sol(abs(right));
        }
    }
    for (int i = -1;; i--) {
        ll hor = (i + 1) * h + (i % 2 != 0 ? -q : -h + q);
        Line line(Point(-INF, hor), Point(INF, hor));
        if (!intersect(c, line)) break;
        auto cps = crosspoint(c, line);
        Real left = INF;
        Real right = -INF;
        for (auto cp: cps) {
            chmin(left, cp.x);
            chmax(right, cp.x);
        }
        if (lte(0, left)) {
            ans += sol(right) - sol(left - EPS);
        } else if (lte(right, 0)) {
            ans += sol(abs(left)) - sol(abs(right) - EPS);
        } else {
            ans += sol(abs(left)) + sol(abs(right));
        }
    }
    cout << ans << endl;
}
accuracy: 0.08333333333333333
time_ms: 50
memory_kb: 3480
final_rank: 19

code_snippet: #include <bits/stdc++.h>




namespace zawa {

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using i128 = __int128_t;

using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;

using usize = std::size_t;

} // namespace zawa



namespace zawa {

namespace geometryZ2 {

using Zahlen = i128;

namespace internal {

constexpr i32 positive{1};
constexpr i32 zero{0};
constexpr i32 negative{-1};

} // namespace internal

constexpr i32 Sign(Zahlen value) {
    if (value < 0) return internal::negative;
    if (value > 0) return internal::positive;
    return internal::zero;
}

constexpr bool Positive(Zahlen value) {
    return Sign(value) == internal::positive;
}

constexpr bool Zero(Zahlen value) {
    return Sign(value) == internal::zero;
}

constexpr bool Negative(Zahlen value) {
    return Sign(value) == internal::negative;
}

constexpr Zahlen Abs(Zahlen value) {
    return (value > 0 ? value : -value);
}

constexpr Zahlen Square(Zahlen value) {
    return value * value;
}

} // namespace geometryZ2

} // namespace zawa


namespace zawa {

namespace geometryZ2 {

class Point {
private:
    Zahlen x_{}, y_{};
    static constexpr i32 origin{0};
    static constexpr i32 firstQuadrant{1};
    static constexpr i32 secondQuadrant{2};
    static constexpr i32 thirdQuadrant{-2};
    static constexpr i32 forthQuadrant{-1};
public:
    /* constructor */
    Point() = default;
    Point(const Point& p) : x_{p.x()}, y_{p.y()} {}
    Point(Zahlen x, Zahlen y) : x_{x}, y_{y} {}

    /* getter setter */
    Zahlen& x() {
        return x_;
    }
    const Zahlen& x() const {
        return x_;
    }
    Zahlen& y() {
        return y_;
    }
    const Zahlen& y() const {
        return y_;
    }

    /* operator */
    Point& operator=(const Point& p) {
        x() = p.x();
        y() = p.y();
        return *this;
    }
    Point& operator+=(const Point& p) {
        x() += p.x();
        y() += p.y();
        return *this;
    }
    friend Point operator+(const Point& p0, const Point& p1) {
        return Point{p0} += p1;
    }
    Point& operator-=(const Point& p) {
        x() -= p.x();
        y() -= p.y();
        return *this;
    }
    friend Point operator-(const Point& p0, const Point& p1) {
        return Point{p0} -= p1;
    }
    Point& operator*=(Zahlen k) {
        x() *= k;
        y() *= k;
        return *this;
    }
    friend Point operator*(const Point& p, Zahlen k) {
        return Point{p} *= k;
    }
    friend Point operator*(Zahlen k, const Point& p) {
        return Point{p} *= k;
    }
    Point& operator/=(Zahlen k) {
        assert(k);
        assert(x() % k == 0);
        assert(y() % k == 0);
        x() /= k;
        y() /= k;
        return *this;
    }
    friend Point operator/(const Point& p, Zahlen k) {
        return Point{p} /= k;
    }
    friend bool operator==(const Point& p0, const Point& p1) {
        return p0.x() == p1.x() and p0.y() == p1.y();
    }
    friend bool operator!=(const Point& p0, const Point& p1) {
        return p0.x() != p1.x() or p0.y() != p1.y();
    }
    friend bool operator<(const Point& p0, const Point& p1) {
        if (p0.x() != p1.x()) return p0.x() < p1.x();
        else return p0.y() < p1.y();
    }
    friend bool operator<=(const Point& p0, const Point& p1) {
        return (p0 < p1) or (p0 == p1);
    }
    friend bool operator>(const Point& p0, const Point& p1) {
        if (p0.x() != p1.x()) return p0.x() > p1.x();
        else return p0.y() > p1.y();
    }
    friend bool operator>=(const Point& p0, const Point& p1) {
        return (p0 > p1) or (p0 == p1);
    }
    //friend std::istream& operator>>(std::istream& is, Point& p) {
    //    is >> p.x() >> p.y();
    //    return is;
    //}
    //friend std::ostream& operator<<(std::ostream& os, const Point& p) {
    //    os << '(' << p.x() << ',' << p.y() << ')';
    //    return os;
    //}

    /* member function */
    Zahlen normSquare() const {
        return Square(x()) + Square(y());
    }

    i32 area() const {
        if (x_ == 0 and y_ == 0) return origin;
        if (x_ <= 0 and y_ < 0) return thirdQuadrant;
        if (x_ > 0 and y_ <= 0) return forthQuadrant;
        if (x_ >= 0 and y_ > 0) return firstQuadrant;
        return secondQuadrant;
    }

    /* static member */
    static bool ArgComp(const Point& p0, const Point& p1) {
        if (p0.area() != p1.area()) return p0.area() < p1.area();
        Zahlen cross{Cross(p0, p1)};
        return (!Zero(cross) ? Positive(cross) : p0.normSquare() < p1.normSquare());
    }

    /* friend function */
    friend Zahlen Dot(const Point& p0, const Point& p1) {
        return p0.x() * p1.x() + p0.y() * p1.y();
    }
    friend Zahlen Cross(const Point& p0, const Point& p1) {
        return p0.x() * p1.y() - p0.y() * p1.x();
    }
};
using Vector = Point;

} // namespace geometryZ2

} // namespace zawa



namespace zawa {

namespace geometryZ2 {

Zahlen DistanceSquare(const Point& p0, const Point& p1) {
    return Vector{p1 - p0}.normSquare();
}

} // namespace geometryZ2

} // namespace zawa


namespace zawa {

namespace geometryZ2 {

class Circle {
private:
    Point center_{};
    Zahlen radius_{};
public:
    /* constructor */
    Circle() = default;
    Circle(const Point& center, const Zahlen radius) : center_{center}, radius_{radius} {
        assert(!Negative(radius_));
    }

    /* getter, setter */
    Point& center() {
        return center_;
    }
    const Point& center() const {
        return center_;
    }
    Zahlen& radius() {
        return radius_;
    }
    const Zahlen& radius() const {
        return radius_;
    }

    /* operator */
    Circle& operator=(const Circle& c) {
        radius_ = c.radius();
        center_ = c.center();
        return *this;
    }
    friend bool operator==(const Circle& c0, const Circle& c1) {
        return c0.radius() == c1.radius() and c0.center() == c1.center();
    }
    friend bool operator!=(const Circle& c0, const Circle& c1) {
        return c0.radius() != c1.radius() or c0.center() != c1.center();
    }

    /* member */
    
    Zahlen radiusSquare() const {
        return Square(radius_);
    }

    /* friend function */
    friend u32 NumberCommonTangent(const Circle& c0, const Circle& c1) {
        Zahlen dist{DistanceSquare(c0.center(), c1.center())};
        Zahlen down{Square(Abs(c0.radius() - c1.radius()))};
        if (dist < down) {
            return 0;
        }
        if (dist == down) {
            return 1;
        }
        Zahlen up{Square(c0.radius() + c1.radius())}; 
        if (dist < up) {
            return 2;
        }
        if (dist == up) {
            return 3;
        }
        return 4;
    }
};

} // namespace geometryZ2

} // namespace zawa


namespace zawa {

namespace geometryZ2 {

enum ContainState {
    INSIDE          = 0,
    ONLINE          = 1,
    OUTSIDE         = 2
};

} // namespace geometryZ2

} // namespace zawa

namespace zawa {

namespace geometryZ2 {

ContainState CircleContainsPoint(const Circle& c, const Point& p) {
    Zahlen dist{DistanceSquare(c.center(), p)};
    if (dist < c.radiusSquare()) {
        return INSIDE;
    }
    else if (dist == c.radiusSquare()) {
        return ONLINE;
    }
    else {
        return OUTSIDE;
    }
}

} // namespace geometryZ2

} // namespace zawa

using namespace zawa::geometryZ2;

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    long long W, H, V, T, X, Y, P, Q;
    std::cin >> W >> H >> V >> T >> X >> Y >> P >> Q;
    Circle wave{Point{ X, Y }, V * T};

    //const long long INVALID{(long long)9e18};
    // 部屋(x, y)にいるビックブリッジ伯爵のx座標を返す。
    auto calcX{[&](long long x) -> long long {
        if (x >= 0) {
            long long res{x * W};
            if (x % 2) res += W - P;
            else res += P;
            return res;
        }
        else {
            long long res{x * W};
            if (x % 2) res += W - P;
            else res += P;
            return res;
        }
    }};
    // 部屋(x, y)にいるビックブリッジ伯爵のy座標を返す。
    auto calcY{[&](long long y) -> long long {
        if (y >= 0) {
            long long res{y * H};
            if (y % 2) res += H - Q;
            else res += Q;
            return res;
        }
        else {
            long long res{y * H};
            if (y % 2) res += H - Q;
            else res += Q;
            return res;
        }
    }};
    auto hito{[&](long long x, long long y) -> Point {
        return Point{ calcX(x), calcY(y) };
    }};
    // 部屋(x, y)にいるビックブリッジ伯爵に衝撃波が当たるか？
    auto contains{[&](long long x, long long y) -> bool {
        Point pos{hito(x, y)};
        return CircleContainsPoint(wave, pos) != OUTSIDE;
    }};
    long long ans{};
    for (int x{-1000000} ; x <= 1000000 ; x++) {
        if (!contains(x, 0LL)) continue;
        { // 上側
            long long ok{0}, ng{1000000};
            while (std::abs(ok - ng) > 1) {
                long long mid{(ok + ng) / 2};
                if (contains(x, mid)) {
                    ok = mid;
                }
                else {
                    ng = mid;
                }
            }
            ans += ng;
        }
        { // 下側
            long long ok{0}, ng{-1000000};
            while (std::abs(ok - ng) > 1) {
                long long mid{(ok + ng) / 2};
                if (contains(x, mid)) {
                    ok = mid;
                }
                else {
                    ng = mid;
                }
            }
            ans += std::abs(ng);
        }
        ans--;
    }
    std::cout << ans << '\n';
}
accuracy: 1
time_ms: 220
memory_kb: 3460
final_rank: 6

code_snippet: #include <bits/stdc++.h>




namespace zawa {

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using i128 = __int128_t;

using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;

using usize = std::size_t;

} // namespace zawa



namespace zawa {

namespace geometryZ2 {

using Zahlen = i64;

namespace internal {

constexpr i32 positive{1};
constexpr i32 zero{0};
constexpr i32 negative{-1};

} // namespace internal

constexpr i32 Sign(Zahlen value) {
    if (value < 0) return internal::negative;
    if (value > 0) return internal::positive;
    return internal::zero;
}

constexpr bool Positive(Zahlen value) {
    return Sign(value) == internal::positive;
}

constexpr bool Zero(Zahlen value) {
    return Sign(value) == internal::zero;
}

constexpr bool Negative(Zahlen value) {
    return Sign(value) == internal::negative;
}

constexpr Zahlen Abs(Zahlen value) {
    return (value > 0 ? value : -value);
}

constexpr Zahlen Square(Zahlen value) {
    return value * value;
}

} // namespace geometryZ2

} // namespace zawa


namespace zawa {

namespace geometryZ2 {

class Point {
private:
    Zahlen x_{}, y_{};
    static constexpr i32 origin{0};
    static constexpr i32 firstQuadrant{1};
    static constexpr i32 secondQuadrant{2};
    static constexpr i32 thirdQuadrant{-2};
    static constexpr i32 forthQuadrant{-1};
public:
    /* constructor */
    Point() = default;
    Point(const Point& p) : x_{p.x()}, y_{p.y()} {}
    Point(Zahlen x, Zahlen y) : x_{x}, y_{y} {}

    /* getter setter */
    Zahlen& x() {
        return x_;
    }
    const Zahlen& x() const {
        return x_;
    }
    Zahlen& y() {
        return y_;
    }
    const Zahlen& y() const {
        return y_;
    }

    /* operator */
    Point& operator=(const Point& p) {
        x() = p.x();
        y() = p.y();
        return *this;
    }
    Point& operator+=(const Point& p) {
        x() += p.x();
        y() += p.y();
        return *this;
    }
    friend Point operator+(const Point& p0, const Point& p1) {
        return Point{p0} += p1;
    }
    Point& operator-=(const Point& p) {
        x() -= p.x();
        y() -= p.y();
        return *this;
    }
    friend Point operator-(const Point& p0, const Point& p1) {
        return Point{p0} -= p1;
    }
    Point& operator*=(Zahlen k) {
        x() *= k;
        y() *= k;
        return *this;
    }
    friend Point operator*(const Point& p, Zahlen k) {
        return Point{p} *= k;
    }
    friend Point operator*(Zahlen k, const Point& p) {
        return Point{p} *= k;
    }
    Point& operator/=(Zahlen k) {
        assert(k);
        assert(x() % k == 0);
        assert(y() % k == 0);
        x() /= k;
        y() /= k;
        return *this;
    }
    friend Point operator/(const Point& p, Zahlen k) {
        return Point{p} /= k;
    }
    friend bool operator==(const Point& p0, const Point& p1) {
        return p0.x() == p1.x() and p0.y() == p1.y();
    }
    friend bool operator!=(const Point& p0, const Point& p1) {
        return p0.x() != p1.x() or p0.y() != p1.y();
    }
    friend bool operator<(const Point& p0, const Point& p1) {
        if (p0.x() != p1.x()) return p0.x() < p1.x();
        else return p0.y() < p1.y();
    }
    friend bool operator<=(const Point& p0, const Point& p1) {
        return (p0 < p1) or (p0 == p1);
    }
    friend bool operator>(const Point& p0, const Point& p1) {
        if (p0.x() != p1.x()) return p0.x() > p1.x();
        else return p0.y() > p1.y();
    }
    friend bool operator>=(const Point& p0, const Point& p1) {
        return (p0 > p1) or (p0 == p1);
    }
    friend std::istream& operator>>(std::istream& is, Point& p) {
        is >> p.x() >> p.y();
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, const Point& p) {
        os << '(' << p.x() << ',' << p.y() << ')';
        return os;
    }

    /* member function */
    Zahlen normSquare() const {
        return Square(x()) + Square(y());
    }

    i32 area() const {
        if (x_ == 0 and y_ == 0) return origin;
        if (x_ <= 0 and y_ < 0) return thirdQuadrant;
        if (x_ > 0 and y_ <= 0) return forthQuadrant;
        if (x_ >= 0 and y_ > 0) return firstQuadrant;
        return secondQuadrant;
    }

    /* static member */
    static bool ArgComp(const Point& p0, const Point& p1) {
        if (p0.area() != p1.area()) return p0.area() < p1.area();
        Zahlen cross{Cross(p0, p1)};
        return (!Zero(cross) ? Positive(cross) : p0.normSquare() < p1.normSquare());
    }

    /* friend function */
    friend Zahlen Dot(const Point& p0, const Point& p1) {
        return p0.x() * p1.x() + p0.y() * p1.y();
    }
    friend Zahlen Cross(const Point& p0, const Point& p1) {
        return p0.x() * p1.y() - p0.y() * p1.x();
    }
};
using Vector = Point;

} // namespace geometryZ2

} // namespace zawa



namespace zawa {

namespace geometryZ2 {

Zahlen DistanceSquare(const Point& p0, const Point& p1) {
    return Vector{p1 - p0}.normSquare();
}

} // namespace geometryZ2

} // namespace zawa


namespace zawa {

namespace geometryZ2 {

class Circle {
private:
    Point center_{};
    Zahlen radius_{};
public:
    /* constructor */
    Circle() = default;
    Circle(const Point& center, const Zahlen radius) : center_{center}, radius_{radius} {
        assert(!Negative(radius_));
    }

    /* getter, setter */
    Point& center() {
        return center_;
    }
    const Point& center() const {
        return center_;
    }
    Zahlen& radius() {
        return radius_;
    }
    const Zahlen& radius() const {
        return radius_;
    }

    /* operator */
    Circle& operator=(const Circle& c) {
        radius_ = c.radius();
        center_ = c.center();
        return *this;
    }
    friend bool operator==(const Circle& c0, const Circle& c1) {
        return c0.radius() == c1.radius() and c0.center() == c1.center();
    }
    friend bool operator!=(const Circle& c0, const Circle& c1) {
        return c0.radius() != c1.radius() or c0.center() != c1.center();
    }

    /* member */
    
    Zahlen radiusSquare() const {
        return Square(radius_);
    }

    /* friend function */
    friend u32 NumberCommonTangent(const Circle& c0, const Circle& c1) {
        Zahlen dist{DistanceSquare(c0.center(), c1.center())};
        Zahlen down{Square(Abs(c0.radius() - c1.radius()))};
        if (dist < down) {
            return 0;
        }
        if (dist == down) {
            return 1;
        }
        Zahlen up{Square(c0.radius() + c1.radius())}; 
        if (dist < up) {
            return 2;
        }
        if (dist == up) {
            return 3;
        }
        return 4;
    }
};

} // namespace geometryZ2

} // namespace zawa


namespace zawa {

namespace geometryZ2 {

enum ContainState {
    INSIDE          = 0,
    ONLINE          = 1,
    OUTSIDE         = 2
};

} // namespace geometryZ2

} // namespace zawa

namespace zawa {

namespace geometryZ2 {

ContainState CircleContainsPoint(const Circle& c, const Point& p) {
    Zahlen dist{DistanceSquare(c.center(), p)};
    if (dist < c.radiusSquare()) {
        return INSIDE;
    }
    else if (dist == c.radiusSquare()) {
        return ONLINE;
    }
    else {
        return OUTSIDE;
    }
}

} // namespace geometryZ2

} // namespace zawa

using namespace zawa::geometryZ2;

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    long long W, H, V, T, X, Y, P, Q;
    std::cin >> W >> H >> V >> T >> X >> Y >> P >> Q;
    Circle wave{Point{ X, Y }, V * T};

    //const long long INVALID{(long long)9e18};
    // 部屋(x, y)にいるビックブリッジ伯爵のx座標を返す。
    auto calcX{[&](long long x) -> long long {
        if (x >= 0) {
            long long res{x * W};
            if (x % 2) res += W - P;
            else res += P;
            return res;
        }
        else {
            long long res{x * W};
            if (x % 2) res += W - P;
            else res += P;
            return res;
        }
    }};
    // 部屋(x, y)にいるビックブリッジ伯爵のy座標を返す。
    auto calcY{[&](long long y) -> long long {
        if (y >= 0) {
            long long res{y * H};
            if (y % 2) res += H - Q;
            else res += Q;
            return res;
        }
        else {
            long long res{y * H};
            if (y % 2) res += H - Q;
            else res += Q;
            return res;
        }
    }};
    auto hito{[&](long long x, long long y) -> Point {
        return Point{ calcX(x), calcY(y) };
    }};
    // 部屋(x, y)にいるビックブリッジ伯爵に衝撃波が当たるか？
    auto contains{[&](long long x, long long y) -> bool {
        Point pos{hito(x, y)};
        return CircleContainsPoint(wave, pos) != OUTSIDE;
    }};
    long long ans{};
    for (int x{-1000000} ; x <= 1000000 ; x++) {
        if (!contains(x, 0LL)) continue;
        { // 上側
            long long ok{0}, ng{1000000};
            while (std::abs(ok - ng) > 1) {
                long long mid{(ok + ng) / 2};
                if (contains(x, mid)) {
                    ok = mid;
                }
                else {
                    ng = mid;
                }
            }
            ans += ng;
        }
        { // 下側
            long long ok{0}, ng{-1000000};
            while (std::abs(ok - ng) > 1) {
                long long mid{(ok + ng) / 2};
                if (contains(x, mid)) {
                    ok = mid;
                }
                else {
                    ng = mid;
                }
            }
            ans += std::abs(ng);
        }
        ans--;
    }
    std::cout << ans << '\n';
}
accuracy: 0.6388888888888888
time_ms: 140
memory_kb: 3468
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
int main(void) {
    ll w, h, v, t, x, y, p, q;
    cin >> w >> h >> v >> t >> x >> y >> p >> q;
    ll ans = 0;
    for(ll i = -1e6; i <= 1e6; ++i) {
        ll X = i * w;
        if(i % 2 == 0) {
            X += p;
        } else {
            X += w - p;
        }
        if(abs(X - x) > v * t) continue;
        auto func = [&](ll dx, ll dy) -> bool {
            return dx * dx + dy * dy <= (v * t) * (v * t);
        };
        if(func(X - x, q - y)) {
            ans++;
        }
        {
            ll lower = 1, upper = 1e6 + 1;
            while(upper - lower > 1) {
                ll mid = (lower + upper) / 2;
                ll Y = mid * h;
                if(mid % 2 == 0) {
                    Y += q;
                } else {
                    Y += h - q;
                }
                if(abs(Y - y) <= v * t and func(X - x, Y - y)) {
                    lower = mid;
                } else {
                    upper = mid;
                }
            }
            ll Y = lower * h;
            if(lower % 2 == 0) {
                Y += q;
            } else {
                Y += h - q;
            }
            if(func(X - x, Y - y)) {
                ans += lower;
            } else {
                ans += lower - 1;
            }
        }
        {
            ll lower = -1e6 - 1, upper = -1;
            while(upper - lower > 1) {
                ll mid = (lower + upper) / 2;
                ll Y = mid * h;
                if(mid % 2 == 0) {
                    Y += q;
                } else {
                    Y += h - q;
                }
                if(abs(Y - y) <= v * t and func(X - x, Y - y)) {
                    upper = mid;
                } else {
                    lower = mid;
                }
            }
            ll Y = upper * h;
            if(upper % 2 == 0) {
                Y += q;
            } else {
                Y += h - q;
            }
            if(func(X - x, Y - y)) {
                ans += -upper;
            } else {
                ans += -upper - 1;
            }
        }
    }
    cout << ans << '\n';
}
accuracy: 1
time_ms: 150
memory_kb: 3452
final_rank: 1

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
int main(void) {
    ll w, h, v, t, x, y, p, q;
    cin >> w >> h >> v >> t >> x >> y >> p >> q;
    ll ans = 0;
    for(ll i = -1e6; i <= 1e6; ++i) {
        ll X = i * w;
        if(i % 2 == 0) {
            X += p;
        } else {
            X += w - p;
        }
        if(abs(X - x) > v * t) continue;
        {
            ll lower = -1, upper = 1e6 + 1;
            while(upper - lower > 1) {
                ll mid = (lower + upper) / 2;
                ll Y = mid * h;
                if(mid % 2 == 0) {
                    Y += q;
                } else {
                    Y += h - q;
                }
                if((X - x) * (X - x) + (Y - y) * (Y - y) <= (v * t) * (v * t)) {
                    lower = mid;
                } else {
                    upper = mid;
                }
            }
            ans += upper;
            if(lower >= 0) ans--;
        }
        {
            ll lower = -1e6 - 1, upper = 1;
            while(upper - lower > 1) {
                ll mid = (lower + upper) / 2;
                ll Y = mid * h;
                if(mid % 2 == 0) {
                    Y += q;
                } else {
                    Y += h - q;
                }
                if((X - x) * (X - x) + (Y - y) * (Y - y) <= (v * t) * (v * t)) {
                    upper = mid;
                } else {
                    lower = mid;
                }
            }
            ans += -lower;
        }
    }
    cout << ans << '\n';
}
accuracy: 0.6388888888888888
time_ms: 130
memory_kb: 3452
final_rank: 10

code_snippet: #include<bits/stdc++.h>
#define int ll
#define rep(i, N) for(int i = 0; i < (int)N; ++i)
#define rep1(i, N) for(int i = 1; i <= (int)N; ++i)
#define per(i, N) for(int i = N-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define bit(n, k) ((n) >> k)
#define pcnt(n) (__builtin_popcount(n))
#define TakAo(ans) ans ? cout << "Takahashi\n" : cout << "Aoki\n"
#define YesNo(ans) ans ? cout << "Yes\n" : cout << "No\n"
#define endl '\n'
#define fi first
#define se second
#define mkpr make_pair
#define mktpl make_tuple
#define eb emplace_back

using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using point = struct{ ll x, y; };
using State = string::const_iterator;
template<class T> using max_heap = priority_queue<T>;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;
template<class T> using vvvec = vec<vvec<T>>;
template<class T> using vvvvec = vvec<vvec<T>>;

constexpr ld EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr ll MOD = (0) ? 998244353 : 1e9+7;
constexpr int NIL = -1;
constexpr int pm[2] = {1, -1};
constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};

ll cel(ll a, ll b){ return (a + b - 1) / b;}
ll Gcd(ll a, ll b){ return b ? Gcd(b, a % b) : abs(a);}
template<class T> T powi(T x, ll exp){
    return exp > 0 ? (exp & 1 ? x : 1) * powi(x * x, exp >> 1) : 1;
}
ll modpow(ll x, ll exp, ll mod){
    x %= mod;
    return exp > 0 ? (exp & 1 ? x : 1) * modpow(x * x, exp >> 1, mod) % mod : 1;
}
template<class T> bool chmin(T &a, T b){ return a > b ? (a = b, true) : 0;}
template<class T>bool chmax(T &a, T b){ return a < b ? (a = b, true) : 0;}

using Pair = pair<int, int>;
using Tpl = tuple<int, int, int>;

void Main(){
    while(1){
        ll W, H, v, t, x, y, p, q;
        cin >> W >> H >> v >> t >> x >> y >> p >> q;

        ll ans = 0;

        ll X[4] = {p, -p, -p, p};
        ll Y[4] = {q, q, -q, -q};

        ll k, yu, yd;
        ll vt2 = v * t * v * t;

        rep(i, 4){
            ll L, R, mid;
            while(abs(X[i] - x) > abs(X[i] - x + 2 * W)) X[i] += 2 * W;
            while(abs(X[i] - x) > abs(X[i] - x - 2 * W)) X[i] -= 2 * W;
            while(abs(Y[i] - y) > abs(Y[i] - y + 2 * H)) Y[i] += 2 * H;
            while(abs(Y[i] - y) > abs(Y[i] - y - 2 * H)) Y[i] -= 2 * H;

            for(k = 0;; k++){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(1){
                    int cnt = 0;
                    rep(j, 7){
                        ll valy = Y[i] - y + 2 * H * (3 - j);
                        valy = abs(valy);
                        if(valy > v * t){
                            cnt++; continue;
                        }
                        if(valx2 + valy * valy > vt2){
                            cnt++; continue;
                        }
                    }
                    if(cnt == 7) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }

            for(k = -1;; k--){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(1){
                    int cnt = 0;
                    rep(j, 7){
                        ll valy = Y[i] - y + 2 * H * (3 - j);
                        valy = abs(valy);
                        if(valy > v * t){
                            cnt++; continue;
                        }
                        if(valx2 + valy * valy > vt2){
                            cnt++; continue;
                        }
                    }
                    if(cnt == 7) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }
            //cout << endl;
        }

        cout << ans << endl;
        break;
    }
}
 
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    Main();
    return 0;
}
accuracy: 1
time_ms: 290
memory_kb: 3452
final_rank: 7

code_snippet: #include<bits/stdc++.h>
#define int ll
#define rep(i, N) for(int i = 0; i < (int)N; ++i)
#define rep1(i, N) for(int i = 1; i <= (int)N; ++i)
#define per(i, N) for(int i = N-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define bit(n, k) ((n) >> k)
#define pcnt(n) (__builtin_popcount(n))
#define TakAo(ans) ans ? cout << "Takahashi\n" : cout << "Aoki\n"
#define YesNo(ans) ans ? cout << "Yes\n" : cout << "No\n"
#define endl '\n'
#define fi first
#define se second
#define mkpr make_pair
#define mktpl make_tuple
#define eb emplace_back

using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using point = struct{ ll x, y; };
using State = string::const_iterator;
template<class T> using max_heap = priority_queue<T>;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;
template<class T> using vvvec = vec<vvec<T>>;
template<class T> using vvvvec = vvec<vvec<T>>;

constexpr ld EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr ll MOD = (0) ? 998244353 : 1e9+7;
constexpr int NIL = -1;
constexpr int pm[2] = {1, -1};
constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};

ll cel(ll a, ll b){ return (a + b - 1) / b;}
ll Gcd(ll a, ll b){ return b ? Gcd(b, a % b) : abs(a);}
template<class T> T powi(T x, ll exp){
    return exp > 0 ? (exp & 1 ? x : 1) * powi(x * x, exp >> 1) : 1;
}
ll modpow(ll x, ll exp, ll mod){
    x %= mod;
    return exp > 0 ? (exp & 1 ? x : 1) * modpow(x * x, exp >> 1, mod) % mod : 1;
}
template<class T> bool chmin(T &a, T b){ return a > b ? (a = b, true) : 0;}
template<class T>bool chmax(T &a, T b){ return a < b ? (a = b, true) : 0;}

using Pair = pair<int, int>;
using Tpl = tuple<int, int, int>;

void Main(){
    while(1){
        ll W, H, v, t, x, y, p, q;
        cin >> W >> H >> v >> t >> x >> y >> p >> q;

        ll ans = 0;

        ll X[4] = {p, -p, -p, p};
        ll Y[4] = {q, q, -q, -q};

        ll k, yu, yd;
        ll vt2 = v * t * v * t;

        rep(i, 4){
            ll L, R, mid;
            while(abs(X[i] - x) > abs(X[i] - x + 2 * W)) X[i] += 2 * W;
            while(abs(X[i] - x) > abs(X[i] - x - 2 * W)) X[i] -= 2 * W;
            while(abs(Y[i] - y) > abs(Y[i] - y + 2 * H)) Y[i] += 2 * H;
            while(abs(Y[i] - y) > abs(Y[i] - y - 2 * H)) Y[i] -= 2 * H;

            for(k = 0;; k++){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(1){
                    int cnt = 0;
                    rep(j, 7){
                        ll valy = Y[i] - y + 2 * H * (3 - j);
                        valy = abs(valy);
                        if(valy > v * t){
                            cnt++; continue;
                        }
                        if(valx2 + valy * valy > vt2){
                            cnt++; continue;
                        }
                    }
                    if(cnt == 7) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }

            for(k = -1;; k--){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(1){
                    int cnt = 0;
                    rep(j, 7){
                        ll valy = Y[i] - y + 2 * H * (3 - j);
                        valy = abs(valy);
                        if(valy > v * t){
                            cnt++; continue;
                        }
                        if(valx2 + valy * valy > vt2){
                            cnt++; continue;
                        }
                    }
                    if(cnt == 7) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }
            //cout << endl;
        }

        cout << ans << endl;
        break;
    }
}
 
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    Main();
    return 0;
}
accuracy: 1
time_ms: 280
memory_kb: 3440
final_rank: 5

code_snippet: #include<bits/stdc++.h>
#define int ll
#define rep(i, N) for(int i = 0; i < (int)N; ++i)
#define rep1(i, N) for(int i = 1; i <= (int)N; ++i)
#define per(i, N) for(int i = N-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define bit(n, k) ((n) >> k)
#define pcnt(n) (__builtin_popcount(n))
#define TakAo(ans) ans ? cout << "Takahashi\n" : cout << "Aoki\n"
#define YesNo(ans) ans ? cout << "Yes\n" : cout << "No\n"
#define endl '\n'
#define fi first
#define se second
#define mkpr make_pair
#define mktpl make_tuple
#define eb emplace_back

using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using point = struct{ ll x, y; };
using State = string::const_iterator;
template<class T> using max_heap = priority_queue<T>;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;
template<class T> using vvvec = vec<vvec<T>>;
template<class T> using vvvvec = vvec<vvec<T>>;

constexpr ld EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr ll MOD = (0) ? 998244353 : 1e9+7;
constexpr int NIL = -1;
constexpr int pm[2] = {1, -1};
constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};

ll cel(ll a, ll b){ return (a + b - 1) / b;}
ll Gcd(ll a, ll b){ return b ? Gcd(b, a % b) : abs(a);}
template<class T> T powi(T x, ll exp){
    return exp > 0 ? (exp & 1 ? x : 1) * powi(x * x, exp >> 1) : 1;
}
ll modpow(ll x, ll exp, ll mod){
    x %= mod;
    return exp > 0 ? (exp & 1 ? x : 1) * modpow(x * x, exp >> 1, mod) % mod : 1;
}
template<class T> bool chmin(T &a, T b){ return a > b ? (a = b, true) : 0;}
template<class T>bool chmax(T &a, T b){ return a < b ? (a = b, true) : 0;}

using Pair = pair<int, int>;
using Tpl = tuple<int, int, int>;

void Main(){
    while(1){
        ll W, H, v, t, x, y, p, q;
        cin >> W >> H >> v >> t >> x >> y >> p >> q;

        ll ans = 0;

        ll X[4] = {p, -p, -p, p};
        ll Y[4] = {q, q, -q, -q};

        ll k, yu, yd;
        ll vt2 = v * t * v * t;

        rep(i, 4){
            ll L, R, mid;
            while(abs(X[i] - x) > abs(X[i] - x + 2 * W * k)) X[i] += 2 * W * k;
            while(abs(X[i] - x) > abs(X[i] - x - 2 * W * k)) X[i] -= 2 * W * k;

            for(k = 0;; k++){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(1){
                    int cnt = 0;
                    rep(j, 7){
                        ll valy = Y[i] - y + 2 * H * (3 - j);
                        valy = abs(valy);
                        if(valy > v * t){
                            cnt++; continue;
                        }
                        if(valx2 + valy * valy > vt2){
                            cnt++; continue;
                        }
                    }
                    if(cnt == 7) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }

            for(k = -1;; k--){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(1){
                    int cnt = 0;
                    rep(j, 7){
                        ll valy = Y[i] - y + 2 * H * (3 - j);
                        valy = abs(valy);
                        if(valy > v * t){
                            cnt++; continue;
                        }
                        if(valx2 + valy * valy > vt2){
                            cnt++; continue;
                        }
                    }
                    if(cnt == 7) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }
            //cout << endl;
        }

        cout << ans << endl;
        break;
    }
}
 
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    Main();
    return 0;
}
accuracy: 0.6388888888888888
time_ms: 290
memory_kb: 3440
final_rank: 13

code_snippet: #include<bits/stdc++.h>
#define int ll
#define rep(i, N) for(int i = 0; i < (int)N; ++i)
#define rep1(i, N) for(int i = 1; i <= (int)N; ++i)
#define per(i, N) for(int i = N-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define bit(n, k) ((n) >> k)
#define pcnt(n) (__builtin_popcount(n))
#define TakAo(ans) ans ? cout << "Takahashi\n" : cout << "Aoki\n"
#define YesNo(ans) ans ? cout << "Yes\n" : cout << "No\n"
#define endl '\n'
#define fi first
#define se second
#define mkpr make_pair
#define mktpl make_tuple
#define eb emplace_back

using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using point = struct{ ll x, y; };
using State = string::const_iterator;
template<class T> using max_heap = priority_queue<T>;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;
template<class T> using vvvec = vec<vvec<T>>;
template<class T> using vvvvec = vvec<vvec<T>>;

constexpr ld EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr ll MOD = (0) ? 998244353 : 1e9+7;
constexpr int NIL = -1;
constexpr int pm[2] = {1, -1};
constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};

ll cel(ll a, ll b){ return (a + b - 1) / b;}
ll Gcd(ll a, ll b){ return b ? Gcd(b, a % b) : abs(a);}
template<class T> T powi(T x, ll exp){
    return exp > 0 ? (exp & 1 ? x : 1) * powi(x * x, exp >> 1) : 1;
}
ll modpow(ll x, ll exp, ll mod){
    x %= mod;
    return exp > 0 ? (exp & 1 ? x : 1) * modpow(x * x, exp >> 1, mod) % mod : 1;
}
template<class T> bool chmin(T &a, T b){ return a > b ? (a = b, true) : 0;}
template<class T>bool chmax(T &a, T b){ return a < b ? (a = b, true) : 0;}

using Pair = pair<int, int>;
using Tpl = tuple<int, int, int>;

void Main(){
    while(1){
        ll W, H, v, t, x, y, p, q;
        cin >> W >> H >> v >> t >> x >> y >> p >> q;

        ll ans = 0;
        ll X[4] = {p, -p, -p, p};
        ll Y[4] = {q, q, -q, -q};

        ll k, yu, yd;
        ll vt2 = v * t * v * t;

        rep(i, 4){
            ll L, R, mid;

            for(k = 0;; k++){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(1){
                    int cnt = 0;
                    rep(j, 7){
                        ll valy = Y[i] - y + 2 * H * (3 - j);
                        valy = abs(valy);
                        if(valy > v * t){
                            cnt++; continue;
                        }
                        if(valx2 + valy * valy > vt2){
                            cnt++; continue;
                        }
                    }
                    if(cnt == 7) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }

            for(k = -1;; k--){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(1){
                    int cnt = 0;
                    rep(j, 7){
                        ll valy = Y[i] - y + 2 * H * (3 - j);
                        valy = abs(valy);
                        if(valy > v * t){
                            cnt++; continue;
                        }
                        if(valx2 + valy * valy > vt2){
                            cnt++; continue;
                        }
                    }
                    if(cnt == 7) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }
        }

        cout << ans << endl;
        break;
    }
}
 
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    Main();
    return 0;
}
accuracy: 0.1388888888888889
time_ms: 290
memory_kb: 3440
final_rank: 18

code_snippet: #include<bits/stdc++.h>
#define int ll
#define rep(i, N) for(int i = 0; i < (int)N; ++i)
#define rep1(i, N) for(int i = 1; i <= (int)N; ++i)
#define per(i, N) for(int i = N-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define bit(n, k) ((n) >> k)
#define pcnt(n) (__builtin_popcount(n))
#define TakAo(ans) ans ? cout << "Takahashi\n" : cout << "Aoki\n"
#define YesNo(ans) ans ? cout << "Yes\n" : cout << "No\n"
#define endl '\n'
#define fi first
#define se second
#define mkpr make_pair
#define mktpl make_tuple
#define eb emplace_back

using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using point = struct{ ll x, y; };
using State = string::const_iterator;
template<class T> using max_heap = priority_queue<T>;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;
template<class T> using vvvec = vec<vvec<T>>;
template<class T> using vvvvec = vvec<vvec<T>>;

constexpr ld EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr ll MOD = (0) ? 998244353 : 1e9+7;
constexpr int NIL = -1;
constexpr int pm[2] = {1, -1};
constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};

ll cel(ll a, ll b){ return (a + b - 1) / b;}
ll Gcd(ll a, ll b){ return b ? Gcd(b, a % b) : abs(a);}
template<class T> T powi(T x, ll exp){
    return exp > 0 ? (exp & 1 ? x : 1) * powi(x * x, exp >> 1) : 1;
}
ll modpow(ll x, ll exp, ll mod){
    x %= mod;
    return exp > 0 ? (exp & 1 ? x : 1) * modpow(x * x, exp >> 1, mod) % mod : 1;
}
template<class T> bool chmin(T &a, T b){ return a > b ? (a = b, true) : 0;}
template<class T>bool chmax(T &a, T b){ return a < b ? (a = b, true) : 0;}

using Pair = pair<int, int>;
using Tpl = tuple<int, int, int>;

void Main(){
    while(1){
        ll W, H, v, t, x, y, p, q;
        cin >> W >> H >> v >> t >> x >> y >> p >> q;

        ll ans = 0;
        ll X[4] = {p, -p, -p, p};
        ll Y[4] = {q, q, -q, -q};

        ll k, yu, yd;
        ll vt2 = v * t * v * t;

        rep(i, 4){
            ll L, R, mid;

            for(k = 0;; k++){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(yu == yd){
                    int cnt = 0;
                    rep(j, 5){
                        ll valy = Y[i] - y + 2 * H * (2 - j);
                        valy = abs(valy);
                        if(valy > v * t){
                            cnt++; continue;
                        }
                        if(valx2 + valy * valy > vt2){
                            cnt++; continue;
                        }
                    }
                    if(cnt == 5) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }

            for(k = -1;; k--){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(yu == yd){
                    int cnt = 0;
                    rep(j, 5){
                        ll valy = Y[i] - y + 2 * H * (2 - j);
                        valy = abs(valy);
                        if(valy > v * t){
                            cnt++; continue;
                        }
                        if(valx2 + valy * valy > vt2){
                            cnt++; continue;
                        }
                    }
                    if(cnt == 5) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }
        }

        cout << ans << endl;
        break;
    }
}
 
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    Main();
    return 0;
}
accuracy: 0.1388888888888889
time_ms: 300
memory_kb: 3372
final_rank: 16

code_snippet: #include<bits/stdc++.h>
#define int ll
#define rep(i, N) for(int i = 0; i < (int)N; ++i)
#define rep1(i, N) for(int i = 1; i <= (int)N; ++i)
#define per(i, N) for(int i = N-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define bit(n, k) ((n) >> k)
#define pcnt(n) (__builtin_popcount(n))
#define TakAo(ans) ans ? cout << "Takahashi\n" : cout << "Aoki\n"
#define YesNo(ans) ans ? cout << "Yes\n" : cout << "No\n"
#define endl '\n'
#define fi first
#define se second
#define mkpr make_pair
#define mktpl make_tuple
#define eb emplace_back

using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using point = struct{ ll x, y; };
using State = string::const_iterator;
template<class T> using max_heap = priority_queue<T>;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;
template<class T> using vvvec = vec<vvec<T>>;
template<class T> using vvvvec = vvec<vvec<T>>;

constexpr ld EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr ll MOD = (0) ? 998244353 : 1e9+7;
constexpr int NIL = -1;
constexpr int pm[2] = {1, -1};
constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};

ll cel(ll a, ll b){ return (a + b - 1) / b;}
ll Gcd(ll a, ll b){ return b ? Gcd(b, a % b) : abs(a);}
template<class T> T powi(T x, ll exp){
    return exp > 0 ? (exp & 1 ? x : 1) * powi(x * x, exp >> 1) : 1;
}
ll modpow(ll x, ll exp, ll mod){
    x %= mod;
    return exp > 0 ? (exp & 1 ? x : 1) * modpow(x * x, exp >> 1, mod) % mod : 1;
}
template<class T> bool chmin(T &a, T b){ return a > b ? (a = b, true) : 0;}
template<class T>bool chmax(T &a, T b){ return a < b ? (a = b, true) : 0;}

using Pair = pair<int, int>;
using Tpl = tuple<int, int, int>;

void Main(){
    while(1){
        ll W, H, v, t, x, y, p, q;
        cin >> W >> H >> v >> t >> x >> y >> p >> q;

        ll ans = 0;
        ll X[4] = {p, -p, -p, p};
        ll Y[4] = {q, q, -q, -q};

        ll k, yu, yd;
        ll vt2 = v * t * v * t;

        rep(i, 4){
            ll L, R, mid;

            for(k = 0;; k++){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(yu == yd){
                    ll valy = Y[i] - y + 2 * H * yu;
                    valy = abs(valy);
                    if(valy > v * t) break;
                    if(valx2 + valy * valy > vt2) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }

            for(k = -1;; k--){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(yu == yd){
                    ll valy = Y[i] - y + 2 * H * yu;
                    valy = abs(valy);
                    if(valy > v * t) break;
                    if(valx2 + valy * valy > vt2) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }
        }

        cout << ans << endl;
        break;
    }
}
 
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    Main();
    return 0;
}
accuracy: 0.1388888888888889
time_ms: 270
memory_kb: 3372
final_rank: 15

code_snippet: #include<bits/stdc++.h>
#define int ll
#define rep(i, N) for(int i = 0; i < (int)N; ++i)
#define rep1(i, N) for(int i = 1; i <= (int)N; ++i)
#define per(i, N) for(int i = N-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define bit(n, k) ((n) >> k)
#define pcnt(n) (__builtin_popcount(n))
#define TakAo(ans) ans ? cout << "Takahashi\n" : cout << "Aoki\n"
#define YesNo(ans) ans ? cout << "Yes\n" : cout << "No\n"
#define endl '\n'
#define fi first
#define se second
#define mkpr make_pair
#define mktpl make_tuple
#define eb emplace_back

using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using point = struct{ ll x, y; };
using State = string::const_iterator;
template<class T> using max_heap = priority_queue<T>;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;
template<class T> using vvvec = vec<vvec<T>>;
template<class T> using vvvvec = vvec<vvec<T>>;

constexpr ld EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr ll MOD = (0) ? 998244353 : 1e9+7;
constexpr int NIL = -1;
constexpr int pm[2] = {1, -1};
constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};

ll cel(ll a, ll b){ return (a + b - 1) / b;}
ll Gcd(ll a, ll b){ return b ? Gcd(b, a % b) : abs(a);}
template<class T> T powi(T x, ll exp){
    return exp > 0 ? (exp & 1 ? x : 1) * powi(x * x, exp >> 1) : 1;
}
ll modpow(ll x, ll exp, ll mod){
    x %= mod;
    return exp > 0 ? (exp & 1 ? x : 1) * modpow(x * x, exp >> 1, mod) % mod : 1;
}
template<class T> bool chmin(T &a, T b){ return a > b ? (a = b, true) : 0;}
template<class T>bool chmax(T &a, T b){ return a < b ? (a = b, true) : 0;}

using Pair = pair<int, int>;
using Tpl = tuple<int, int, int>;

void Main(){
    while(1){
        ll W, H, v, t, x, y, p, q;
        cin >> W >> H >> v >> t >> x >> y >> p >> q;

        ll ans = 0;
        ll X[4] = {p, -p, -p, p};
        ll Y[4] = {q, q, -q, -q};

        ll k, yu, yd;
        ll vt2 = v * t * v * t;

        rep(i, 4){
            ll L, R, mid;

            for(k = 0;; k++){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(yu == yd){
                    ll valy = Y[i] - y + 2 * H * yu;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    if(valx2 + valy * valy > vt2) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }

            for(k = -1;; k--){
                ll valx2 = X[i] - x + 2 * W * k;
                valx2 = abs(valx2);
                if(valx2 > v * t) break;
                valx2 = valx2 * valx2;

                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * mid;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yu = L;
                L = 0, R = 1e9;
                while(L < R - 1){
                    mid = (L + R) / 2;
                    ll valy = Y[i] - y + 2 * H * (-mid);
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    else if(valx2 + valy * valy <= vt2) L = mid;
                    else R = mid;
                }
                yd = -L;

                if(yu == yd){
                    ll valy = Y[i] - y + 2 * H * yu;
                    valy = abs(valy);
                    if(valy > v * t) R = mid;
                    if(valx2 + valy * valy > vt2) break;
                }

                ans += yu - yd + 1;
                //cout << yu << " " << yd << " | ";
            }
        }

        cout << ans << endl;
        break;
    }
}
 
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    Main();
    return 0;
}
accuracy: 0.1388888888888889
time_ms: 270
memory_kb: 3440
final_rank: 17

code_snippet: #include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
    ll modpow(ll x, ll b,ll mod=MOD){
        ll res = 1;
        while(b){
            if(b&1)res = res * x % mod;
            x = x * x % mod;
            b>>=1;
        }
        return res;
    }

    ll modinv(ll x){
        return modpow(x, MOD-2);
    }

    bool was_output = false;

    void print();
    template <class t> void print(const vector<t> &);
    template <class t, class u> void print(const pair<t, u> &);
    template <class t> void print(const t&);
    template <class Head, class... Tail> void print(const Head&, const Tail&...);

    template <class t> void println(const vector<vector<t>>&);
    template <class t> void println(const vector<t>&);
    template <class t> void println(const t&);
    template <class Head, class... Tail> void println(const Head&, const Tail&...);
    void println();
    void newline();

    void print(){
        return;
    }

    template <class t>
    void print(const vector<t>&x){
        for(const t&i:x)print(i);
    }
    template <class t, class u>
    void print(const pair<t,u>&p){
        print(p.first);
        print(p.second);
    }
    template <class t>
    void print(const t&x){
        if(was_output)cout<<" ";
        cout<<x;
        was_output = true;
    }
    template <class Head, class... Tail>
    void print(const Head&head,const Tail&...tail){
        print(head);
        print(tail...);
    }

    template<class t>
    void println(const vector<vector<t>>&x){
        for(vector<t> i:x)println(i);
    }
    template<class t>
    void println(const vector<t>&x){
        for(const t&i:x)print(i);
        println();
    }
    template <class t>
    void println(const t&x){
        print(x);
        println();
    }
    void println(){
        if(was_output){
            cout << endl;
            was_output = false;
        }
    }
    template <class Head, class... Tail>
    void println(const Head&head,const Tail&...tail){
        print(head);
        println(tail...);
    }

    void newline(){
        was_output = true;
        println();
    }

    template<class t>
    istream& operator>>(istream&is, vector<t>&x){
        for(auto &i:x)is >> i;
        return is;
    }

    template<class t, class u>
    istream& operator>>(istream&is, pair<t, u>&x){
        is >> x.first >> x.second;
        return is;
    }

    template<class t>
    ostream& operator<<(ostream&os, vector<t> &v){
        os << "{";
        for(t &i:v){
            os << i << ", ";
        }
        os << "}";
        return os;
    }

    template<class t = long long>
    t in(){
        t res; cin >> res; return res;
    }

    template<class t>
    vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
        sort(line.begin(),line.end(),comp);
        return line;
    }

    template<class t>
    vector<t> reversed(vector<t> line){
        reverse(line.begin(),line.end());
        return line;
    }
    string reversed(string str){
        reverse(str.begin(),str.end());
        return str;
    }

    long long gcd(long long a,long long b){
        while(b){
            a %= b;
            swap(a,b);
        }
        return a;
    }

    long long lcm(long long a,long long b){
        return a / gcd(a,b) * b;
    }

    class output_initializer{
    public:
        output_initializer(){
            ios::sync_with_stdio(false);
            cin.tie(nullptr);
            cout << setprecision(20);
        }
    };output_initializer OUTPUT_INITIALIZER_INSTANCE = output_initializer();
}

using namespace templates;

ll func(){
    ll w = in();
    ll h = in();
    ll v = in();
    ll t = in();
    ll x = in();
    ll y = in();
    ll p = in();
    ll q = in();
    pll attack = pll(y,x);
    method(pos,pll,int py,int px){
        ll res_y = q;
        ll res_x = p;
        res_y += h * (py / 2) * 2;
        res_x += w * (px / 2) * 2;
        res_y += (py % 2) * (py > 0 ? (h - q) : q) * 2;
        res_x += (px % 2) * (px > 0 ? (w - p) : p) * 2;
        return pii(res_y,res_x);
    };
        
    ll border = (v * t) * (v * t);
    method(dist,ll,pll x,pll y){
        ll v = x.first - y.first;
        ll u = x.second - y.second;
        return v * v + u * u;
    };
    ll res = 0;
    rep(i,-1100000 / h - 10,1100000 / h + 10){
        int hp = 1100000 / w + 10;
        int lp = 0;
        while(lp + 1 < hp){
            int mid = (hp - lp) / 2 + lp;
            pii p = pos(i,mid);
            if(dist(p,attack) <= border){
                lp = mid;
            }else{
                hp = mid;
            }
        }
        ll top = lp + 2;
        hp = 0;
        lp = -1100000 / w - 10;
        while(lp + 1 < hp){
            int mid = (hp - lp) / 2 + lp;
            pii p = pos(i,mid);
            if(dist(p,attack) <= border){
                hp = mid;
            }else{
                lp = mid;
            }
        }
        ll bottom = lp - 2;
        while(bottom <= top){
            if(dist(pos(i,top),attack) > border){
                --top;
            }else{
                break;
            }
        }
        while(bottom <= top){
            if(dist(pos(i,bottom),attack) > border){
                ++bottom;
            }else{
                break;
            }
        }
        res += max<ll>(0,top - bottom + 1);
        if(top < bottom){
            rep(j,-3,3){
                if(dist(pos(i,j),attack) <= border){
                    ++res;
                }
            }
        }
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    println(func());
    return 0;
}
accuracy: 1
time_ms: 230
memory_kb: 3448
final_rank: 4

code_snippet: #include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
    ll modpow(ll x, ll b,ll mod=MOD){
        ll res = 1;
        while(b){
            if(b&1)res = res * x % mod;
            x = x * x % mod;
            b>>=1;
        }
        return res;
    }

    ll modinv(ll x){
        return modpow(x, MOD-2);
    }

    bool was_output = false;

    void print();
    template <class t> void print(const vector<t> &);
    template <class t, class u> void print(const pair<t, u> &);
    template <class t> void print(const t&);
    template <class Head, class... Tail> void print(const Head&, const Tail&...);

    template <class t> void println(const vector<vector<t>>&);
    template <class t> void println(const vector<t>&);
    template <class t> void println(const t&);
    template <class Head, class... Tail> void println(const Head&, const Tail&...);
    void println();
    void newline();

    void print(){
        return;
    }

    template <class t>
    void print(const vector<t>&x){
        for(const t&i:x)print(i);
    }
    template <class t, class u>
    void print(const pair<t,u>&p){
        print(p.first);
        print(p.second);
    }
    template <class t>
    void print(const t&x){
        if(was_output)cout<<" ";
        cout<<x;
        was_output = true;
    }
    template <class Head, class... Tail>
    void print(const Head&head,const Tail&...tail){
        print(head);
        print(tail...);
    }

    template<class t>
    void println(const vector<vector<t>>&x){
        for(vector<t> i:x)println(i);
    }
    template<class t>
    void println(const vector<t>&x){
        for(const t&i:x)print(i);
        println();
    }
    template <class t>
    void println(const t&x){
        print(x);
        println();
    }
    void println(){
        if(was_output){
            cout << endl;
            was_output = false;
        }
    }
    template <class Head, class... Tail>
    void println(const Head&head,const Tail&...tail){
        print(head);
        println(tail...);
    }

    void newline(){
        was_output = true;
        println();
    }

    template<class t>
    istream& operator>>(istream&is, vector<t>&x){
        for(auto &i:x)is >> i;
        return is;
    }

    template<class t, class u>
    istream& operator>>(istream&is, pair<t, u>&x){
        is >> x.first >> x.second;
        return is;
    }

    template<class t>
    ostream& operator<<(ostream&os, vector<t> &v){
        os << "{";
        for(t &i:v){
            os << i << ", ";
        }
        os << "}";
        return os;
    }

    template<class t = long long>
    t in(){
        t res; cin >> res; return res;
    }

    template<class t>
    vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
        sort(line.begin(),line.end(),comp);
        return line;
    }

    template<class t>
    vector<t> reversed(vector<t> line){
        reverse(line.begin(),line.end());
        return line;
    }
    string reversed(string str){
        reverse(str.begin(),str.end());
        return str;
    }

    long long gcd(long long a,long long b){
        while(b){
            a %= b;
            swap(a,b);
        }
        return a;
    }

    long long lcm(long long a,long long b){
        return a / gcd(a,b) * b;
    }

    class output_initializer{
    public:
        output_initializer(){
            ios::sync_with_stdio(false);
            cin.tie(nullptr);
            cout << setprecision(20);
        }
    };output_initializer OUTPUT_INITIALIZER_INSTANCE = output_initializer();
}

using namespace templates;

ll func(){
    ll w = in();
    ll h = in();
    ll v = in();
    ll t = in();
    ll x = in();
    ll y = in();
    ll p = in();
    ll q = in();
    pll attack = pll(y,x);
    method(pos,pll,int py,int px){
        ll res_y = q;
        ll res_x = p;
        res_y += h * (py / 2) * 2;
        res_x += w * (px / 2) * 2;
        res_y += (py % 2) * (py > 0 ? (h - q) : q) * 2;
        res_x += (px % 2) * (px > 0 ? (w - p) : p) * 2;
        return pii(res_y,res_x);
    };
        
    ll border = (v * t) * (v * t);
    method(dist,ll,pll x,pll y){
        ll v = x.first - y.first;
        ll u = x.second - y.second;
        return v * v + u * u;
    };
    ll res = 0;
    rep(i,-1100000 / h,1100000 / h){
        int hp = 1100000 / w;
        int lp = 0;
        while(lp + 1 < hp){
            int mid = (hp - lp) / 2 + lp;
            pii p = pos(i,mid);
            if(dist(p,attack) <= border){
                lp = mid;
            }else{
                hp = mid;
            }
        }
        ll top = lp + 2;
        hp = 0;
        lp = -1100000 / w;
        while(lp + 1 < hp){
            int mid = (hp - lp) / 2 + lp;
            pii p = pos(i,mid);
            if(dist(p,attack) <= border){
                hp = mid;
            }else{
                lp = mid;
            }
        }
        ll bottom = lp - 2;
        while(bottom <= top){
            if(dist(pos(i,top),attack) > border){
                --top;
            }else{
                break;
            }
        }
        while(bottom <= top){
            if(dist(pos(i,bottom),attack) > border){
                ++bottom;
            }else{
                break;
            }
        }
        res += max<ll>(0,top - bottom + 1);
        if(top < bottom){
            rep(j,-3,3){
                if(dist(pos(i,j),attack) <= border){
                    ++res;
                }
            }
        }
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    println(func());
    return 0;
}
accuracy: 0.6388888888888888
time_ms: 230
memory_kb: 3484
final_rank: 14