1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// Karol Kosinski 2018
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <list>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FOD(i,b,a) for(int i=(b)-1;i>=(a);--i)
//#define DEBUG(x...) printf(x)
#define DEBUG(x...)
using namespace std;

struct Triple { int x_min, x_max, y; };

struct Pit
{
    Pit(unsigned int a, unsigned int b, unsigned int c): a(a), b(b), c(c) {}
    unsigned int a, b, c;
};

struct Point
{
    Point(int x, int y): x(x), y(y) {}
    int x, y;
};

Pit ABC[] = {
    Pit(5, 12, 13), Pit(8, 15, 17), Pit(7, 24, 25),
    Pit(20, 21, 29), Pit(12, 35, 37), Pit(9, 40, 41), Pit(28, 45, 53),
    Pit(11, 60, 61), Pit(16, 63, 65), Pit(33, 56, 65), Pit(48, 55, 73),
    Pit(13, 84, 85), Pit(36, 77, 85), Pit(39, 80, 89), Pit(65, 72, 97),
    Pit(20, 99, 101), Pit(60, 91, 109), Pit(15, 112, 113), Pit(44, 117, 125),
    Pit(88, 105, 137), Pit(17, 144, 145), Pit(24, 143, 145), Pit(51, 140, 149),
    Pit(85, 132, 157), Pit(119, 120, 169), Pit(52, 165, 173), Pit(19, 180, 181),
    Pit(57, 176, 185), Pit(104, 153, 185), Pit(95, 168, 193), Pit(28, 195, 197),
    Pit(84, 187, 205), Pit(133, 156, 205), Pit(21, 220, 221), Pit(140, 171, 221),
    Pit(60, 221, 229), Pit(105, 208, 233), Pit(120, 209, 241)
};
const int ABCsize = sizeof(ABC) / sizeof(Pit);

int XXX[] = {-1, -1, +1, +1};
int YYY[] = {-1, +1, +1, -1};

vector<Point> Ed;
//Point Ed[] = {
//    //Point(-4, 3), Point(-3, 4), Point(0, 1), Point(3, 4), Point(4, 3), Point(1, 0),
//    //Point(4, -3), Point(3, -4), Point(0, -1), Point(-3, -4), Point(-4, -3), Point(-1, 0)
//    Point(-12, 5), Point(-4, 3), Point(-3, 4), Point(-5, 12), Point(0, 1),
//    Point(5, 12), Point(3, 4), Point(4, 3), Point(12, 5), Point(1, 0),
//    Point(12, -5), Point(4, -3), Point(3, -4), Point(5, -12), Point(0, -1),
//    Point(-5, -12), Point(-3, -4), Point(-4, -3), Point(-12, -5), Point(-1, 0)
//};

int EDS = 0; //sizeof(Ed) / sizeof(Point);
int MX_DEPTH = 20;
const Point ZERO = Point(0, 0);

unsigned int x = 6, y = 5;
int depth = 0;
//int shape_counter = 0;
stack<Triple> S;
//vector<Point> V;
map<Point, unsigned int> M;

Point operator + (const Point& a, const Point& b)
{
    return Point(a.x + b.x, a.y + b.y);
}

bool operator < (const Point& a, const Point& b)
{
    if(a.x != b.x) return a.x < b.x;
    return a.y < b.y;
}

bool operator == (const Point& a, const Point& b)
{
    return a.x == b.x and a.y == b.y;
}

int angle(const Point& a, const Point& b, const Point& c)
{
    return (a.x - b.x) * (c.y - b.y)
         - (c.x - b.x) * (a.y - b.y);
}

void dfs(const Point& q, const Point& p)
{
    //V.emplace_back(p.x, p.y);
    //DEBUG("(%d, %d)  ", p.x, p.y);
    //if (depth == 2)
    //{
    //    for(auto& v : V)
    //        DEBUG("(%d, %d)  ", v.x, v.y);
    //    DEBUG("\n");
    //}
    FOR(i,0,EDS)
    {
        auto aim = p + Ed[i];
        auto t = S.top();
        auto ttt = (Triple){min(t.x_min, aim.x),
                            max(t.x_max, aim.x),
                            max(t.y, aim.y)};
        if(x < ttt.x_max - ttt.x_min or y < ttt.y)
        {
            continue;
        }
        if(angle(p, q, aim) > 0)
        {
            if(aim == ZERO and depth > 0)
            {
                ++M[Point(ttt.x_max - ttt.x_min, ttt.y)];
                //++shape_counter;
                //if (ttt.x_max - ttt.x_min == 8 and ttt.y == 7)
                //{
                //    DEBUG("[%d, %d]\n", ttt.x_max - ttt.x_min, ttt.y);
                //    for(auto& v : V)
                //        DEBUG("(%d, %d)  ", v.x, v.y);
                //    DEBUG("\n");
                //}
            }
            else if(aim.y >= 0 and angle(p, ZERO, aim) > 0)
            {
                if(depth < MX_DEPTH)
                {
                    ++depth;
                    S.push(ttt);
                    --EDS;
                    if(i != EDS) swap(Ed[i], Ed[EDS]);
                    dfs(p, aim);
                    if(i != EDS) swap(Ed[i], Ed[EDS]);
                    ++EDS;
                    S.pop();
                    --depth;
                }
            }
        }
    }
    //V.pop_back();
}

void prepare()
{
    EDS = Ed.size();
    MX_DEPTH = EDS;
    S.push((Triple){0, 0, 0});
    FOR(i,0,EDS)
    {
        if(Ed[i].y > 0)
        {
            S.push((Triple){min(Ed[i].x, 0), max(Ed[i].x, 0), max(Ed[i].y, 0)});
            --EDS;
            if(i != EDS) swap(Ed[i], Ed[EDS]);
            dfs(ZERO, Ed[EDS]);
            if(i != EDS) swap(Ed[i], Ed[EDS]);
            ++EDS;
        }
    }
    //DEBUG("\n*** %d\n", shape_counter);
    //for(const auto& m : M)
    //{
    //    DEBUG("-- (%d, %d): %u\n", m.first.x, m.first.y, m.second);
    //}
}

int main()
{
    unsigned int k = 17, res = 0;
    scanf("%u%u%u", &x, &y, &k);
    --x, --y;
    if(k < 5 or x <= 2 or y <= 2)
    {
        res = x * y;
        printf("%u\n", res);
        return 0;
    }
    Ed = { Point(-4, 3), Point(-3, 4), Point(0, 1), Point(3, 4), Point(4, 3), Point(1, 0),
           Point(4, -3), Point(3, -4), Point(0, -1), Point(-3, -4), Point(-4, -3), Point(-1, 0)};
    FOR(i,0,ABCsize)
    {
        const auto& elem = ABC[i];
        if(k >= elem.c)
        {
            FOR(i,0,4) Ed.emplace_back(elem.b * XXX[i], elem.a * YYY[i]);
            FOR(i,0,4) Ed.emplace_back(elem.a * XXX[i], elem.b * YYY[i]);
        }
    }
    prepare();
    for(const auto& m : M)
    {
        //if(x < m.first.x or y < m.first.y) continue;
        DEBUG("-- (%d, %d): %u\n", m.first.x, m.first.y, m.second);
        unsigned int xx = x - m.first.x + 1;
        unsigned int yy = y - m.first.y + 1;
        res += xx * yy * m.second;
    }
    printf("%u\n", res);
    return 0;
}