暴搜代码(耗时较长,要90s左右)如下:
#include <iostream>
using namespace std;
const int N = 15;
int a[N];
bool st[N];
int cnt;void dfs(int u) {if (u == 13) {if (a[1] + a[2] == a[3] && a[4] - a[5] == a[6] && a[7]*a[8] == a[9] && a[11] * a[12] == a[10])cnt++;return ;}for (int i = 1; i <= 13; i++) {if (!st[i]) {a[u] = i;st[i] = true;dfs(u + 1);st[i] = false;a[u] = 0;}}
}int main() {dfs(1);cout << cnt << endl;return 0;
}