Skip to content

Instantly share code, notes, and snippets.

@edwardmjm
Created December 14, 2013 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwardmjm/7966694 to your computer and use it in GitHub Desktop.
Save edwardmjm/7966694 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bitset>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define foreach(it,v) for (__typeof((v).end()) it = (v).begin(); it != (v).end(); it++)
typedef long long ll;
const int N = 105;
ll f[N][N][N];
int main() {
for (int n = 8; n <= 100; n++) {
fprintf(stderr, "%d\n", n);
for (int i = 2; i <= n; i++) {
for (int j = 1; j < i; j++) {
if (n >= 50 && (i + j) >= 4 * n / 3) continue;
ll &cur = f[n][i][j];
cur = 0;
int a[3], b[3], c[3];
for (a[0] = 2; a[0] <= n && a[0] < i + j; a[0]++) if (a[0] != i && a[0] != j) {
for (a[1] = 2; a[1] <= n && a[1] < i + j; a[1]++) if (a[1] != i && a[1] != j && a[1] != a[0]) {
for (a[2] = 2; a[2] <= n && a[2] < i + j; a[2]++) if (a[2] != i && a[2] != j && a[2] != a[0] && a[2] != a[1]) {
rep (o, 3)
if (a[o] > i)
c[o] = b[o] = min(i + j - 1 - a[o], a[o] - 1);
else
c[o] = b[o] = min(i + j - a[o], a[o] - 1);
rep (o, 3) {
if (i <= b[o]) c[o]--;
if (j <= b[o]) c[o]--;
if (a[0] <= b[o]) c[o]--;
if (a[1] <= b[o]) c[o]--;
if (a[2] <= b[o]) c[o]--;
}
if (c[0] > c[1]) swap(c[0], c[1]);
if (c[0] > c[2]) swap(c[0], c[2]);
if (c[1] > c[2]) swap(c[1], c[2]);
if (c[0] > 0 && c[1] > 1 && c[2] > 2)
cur += c[0] * (c[1] - 1) * (c[2] - 2);
}
}
}
}
}
}
rep (i, N) rep (j, N) rep (k, N) cout << f[i][j][k] << " ";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment