QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#127835 | #21608. 行列式 | 1234567890# | RE | 0ms | 0kb | C++14 | 1.9kb | 2023-07-20 09:29:57 | 2023-07-20 09:30:00 |
Judging History
answer
/*
灏忓簾鐗╋紝杩欓兘涓嶄細 /cf
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define inf (ll)1e9
#define pii pair <ll, ll>
#define fr first
#define se second
const ll mod = 998244353;
char buf[1 << 21], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 18, stdin), p1 == p2) ? EOF : *p1++)
inline ll read() {
ll x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9') f = ((ch == '-') ? -1 : f), ch = getchar();
while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
return x * f;
}
inline void write(ll x) {
if(x < 0) x = -x, putchar('-');
if(x >= 10) write(x / 10);
putchar(x % 10 + '0');
}
inline ll quickmod(ll x, ll y) {
ll Ans = 1;
while(y) {
if(y & 1) Ans = (1ll * Ans * x) % mod;
x = (1ll * x * x) % mod;
y >>= 1;
}
return Ans;
}
inline void Add(ll &x, ll y) {
x += y;
if(x >= mod) x -= mod;
}
inline void Dec(ll &x, ll y) {
x -= y;
if(x < 0) x += mod;
}
inline ll add(ll x, ll y) {
x += y;
if(x >= mod) x -= mod;
return x;
}
inline ll dec(ll x, ll y) {
x -= y;
if(x < 0) x += mod;
return x;
}
ll n;
ll a[505][505];
int main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
n = read();
for(ll i = 1; i <= n; i++) for(ll j = 1; j <= n; j++) a[i][j] = read();
ll ans = 1;
for(ll i = 1; i <= n; i++) {
if(!a[i][i]) {
for(ll j = i + 1; j <= n; j++) {
if(!a[i][j] && a[j][i]) {
swap(a[i], a[j]);
ans = mod - ans;
break;
}
}
}
if(!a[i][i]) assert(0);
ll inv = quickmod(a[i][i], mod - 2);
for(ll j = 1; j <= n; j++) {
if(i == j) continue;
ll tmp = a[j][i] * inv % mod;
for(ll k = 1; k <= n; k++) Dec(a[j][k], a[i][k] * tmp % mod);
}
}
for(ll i = 1; i <= n; i++) ans = ans * a[i][i] % mod;
write(ans), putchar('\n');
return 0;
}
/*
*/
详细
Test #1:
score: 0
Dangerous Syscalls
input:
494 507979999 844753235 308697058 577366689 725069158 935333779 504374900 25818576 590205152 640101368 622693010 938297920 872742027 301114974 734834637 556531110 842083217 975440662 921805913 100862321 393656903 213191224 795146059 30475198 812681603 711143306 28681751 642978178 605226383 94538558 ...