标签:
#include <cstdio> #include <cstring> #include <algorithm> #include <vector> using namespace std; typedef __int64 lld; const int MOD = 998244353; const int N = 20; struct Mat { lld a[N][N]; void init(int _a[N][N], int n) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = _a[i][j]; } } } lld * operator [] (int x) { return a[x]; } }AC, C; lld Det(Mat &A, int n) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { C[i][j] = A[i][j] % MOD; } } lld ret = 1; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { while (C[j][i]) { for (int t = C[i][i] / C[j][i], k = 0; k < n; k++) { printf("t = %d\n", t); C[i][k] = (C[i][k] - C[j][k] * t) % MOD; swap(C[i][k], C[j][k]); } ret = - ret; } for(int o = 0; o < n; o ++){ for(int z = 0; z < n; z ++) printf("%d ", C[o][z]); printf("\n"); } } if (C[i][i] == 0) return 0; ret = ret * C[i][i] % MOD; } return ret; } int main(){ int a[N][N] = { {2,3,4}, {3,4,2}, {4,2,3} }; int cur = 4; AC.init(a, cur - 1); printf("%I64d\n", Det(AC, cur - 1)); }
标签:
原文地址:http://www.cnblogs.com/acmood/p/4681087.html