怎么来模拟,记录上下左右前后,转的时候轮换比较简单,记两个再推出其它是错的......
1 #include <iostream> 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 11 #define inf 0x3f3f3f3f12 #define MAXN 13107213 14 using namespace std;15 16 typedef long long ll;17 18 ll n, m, ans;19 ll s, x, z, y, q, h;20 void soll() {21 int t = s;22 s = y, y = x, x = z, z = t;23 ans += s;24 }25 void solr() {26 int t = s;27 s = z, z = x, x = y, y = t;28 ans += s;29 }30 void sold() {31 int t = s;32 s = h, h = x, x = q, q = t;33 ans += s;34 }35 int main() { 36 ans = s = 1, x = 6, z = 4, y = 3, q = 2, h = 5;37 scanf("%lld %lld",&n,&m);38 for(int i = 1; i <= n; i ++){39 ans += ((m - 1) / 4) * 14;40 if(i & 1)41 for(int j = 1; j <= (m - 1) % 4; j ++) solr();42 else43 for(int j = 1; j <= (m - 1) % 4; j ++) soll();44 if(i != n) sold();45 }46 printf("%lld", ans);47 return 0;48 }