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
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 333;
const ll mod = 1LL<<32;

ll dp[N][N];
vector<pii> ps;

ll S[N][N];

int main() {
	int sb=1, sab=1;
	dp[0][0] = dp[1][0] = 1;
	int X, Y, K;
	scanf("%d%d%d", &X, &Y, &K);
	//ps.pb(mp(0,1));
	for (int a = 1; a <= 250; a++) for (int b = a+1; b <= 250; b++) {
		if (__gcd(a,b) > 1) continue;
		int c = sqrt(a*a+b*b);
		if (c <= K && c*c == a*a+b*b) {
			for (int i = N-1; i >= 0; i--) for (int j = N-1; j >= 0; j--) if (dp[i][j]) {
				if (i+a < N && j+b < N) dp[i+a][j+b] += dp[i][j];
			}
			for (int i = N-1; i >= 0; i--) for (int j = N-1; j >= 0; j--) if (dp[i][j]) {
				if (i+b < N && j+a < N) dp[i+b][j+a] += dp[i][j];
			}
			sb += b;
			sab += a+b;
			//printf("%d %d %d\n", a, b, c);
			ps.pb(mp(a,b));
		}
	}
	//printf("sum = %d %d\n", sb, sab);
	int xn = min(X, sab*2+1), yn = min(Y, sab*2+1);
	ll res = 0;
	for (int a=1; a<xn; a++) {
		FOR(i,yn) FOR(j,yn) {
			S[i][j] = 0;
			FOR(k,a+1) {
				S[i][j] += dp[i][k] * dp[a-k][j]%mod;
			}
			//if (S[i][j]>0) printf("%d : S[%d][%d] = %lld\n", a, i, j, S[i][j]);
		}
		for (int b=1; b<yn; b++) {
			FOR(i,b+1) FOR(j,b+1) {
				//if (S[i][j] * S[b-j][b-i]>0) printf("%dx%d : adding %lld (%d %d)\n", a, b, S[i][j] * S[b-j][b-i], i, j);
				res += (X-a) * (Y-b) * S[i][j] * S[b-j][b-i]%mod;
			}
		}
	}
	FOR(i,SZ(ps)) {
		int a = ps[i].fi, b = ps[i].se;
		if (a<=X && b<=Y) res -= 2LL * (X-a) * (Y-b)%mod;
		a = ps[i].se, b = ps[i].fi;
		if (a<=X && b<=Y) res -= 2LL * (X-a) * (Y-b)%mod;
	}
	res %= mod;
	if (res<0) res+=mod;
	printf("%lld\n", res %(1LL<<32));
	return 0;
}