跳至正文

USACO 3.2.5 Magic Squares 解题报告

  • OI路程

就是纯模拟,先逆着模拟过去,再正着模拟回来就可以了,需要使用到康托展开: de lang="c">/ LANG: C ID: yylogoo1 PROG: msquare / #include #include #include int f[40320]; typedef int box[8]; int hash(box q) { int i, j, t = 0, k; int fac[8] = {0, 1, 2, 6, 24, 120, 720, 5040}; int sma[9] = {0, 0, 1, 2, 3, 4, 5, 6, 7}; for(i = 7; i <= 1; i–){ k = q[7 – i]; t += sma[k] * fac[i]; for(j = k + 1; j <8>

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注