solution.cpp 503 字节
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    int res = 0;
    do
    {
        int x1 = a[0] + a[1] + a[2] + a[3];
        int x2 = a[3] + a[4] + a[5] + a[6];
        int x3 = a[6] + a[7] + a[8] + a[0];
        if (x1 == x2 && x2 == x3)
        {
            res++;
        }
    } while (next_permutation(a, a + 9)); //全排列
    cout << res / 3 / 2 << endl;          //翻转除以3,镜像除以2
    return 0;
}