int n = 100;
int minRange = 0;
int maxRange = 1000000000;
LIB "poly.lib";
ring r = 0, x, dp;
int i, j;
poly zero = 0;
poly mlt, p, ratio;
matrix m[n][n];
proc generateMatrix() {
for(i = 1; i <= n; i++) {
for(j = 1; j <= n; j++) {
m[i, j] = random(minRange, maxRange);
}
}
}
proc getDiagonal() {
poly res = 1;
for(i = 1; i <= n; i++) {
res = res * m[i, i];
}
return(res[1][1] / ratio);
}
proc getNotZero(int cl) {
for(i = cl; i <= n; i++) {
if(m[i, cl] != zero) {
return(i);
}
}
return(-1);
}
proc changeRow(int first, int second) {
poly tmp;
for(i = first; i <= n; i++) {
tmp = m[first, i];
m[first, i] = m[second, i];
m[second, i] = tmp;
}
}
proc getLCM(int col) {
int res = 1;
for(i = col; i <= n; i++) {
res = lcm(res, int(m[i, col]));
}
return(res);
}
proc gaussMatrix() {
int i, j, col, row;
ratio = 1;
mlt = 1;
p = 1;
for(col = 1; col <= n; col++) {
row = getNotZero(col);
if(row == -1) {
ratio = 0;
return;
} else {
if(col != row) {
changeRow(col, row);
ratio = ratio * (-1);
}
mlt = getLCM(col);
p = mlt / m[col, col];
ratio = ratio * p;
m = multrow(m, col, p);
for(j = col + 1; j <= n; j++) {
if(m[j, col] != zero) {
p = mlt / m[j, col];
ratio = ratio * p;
for(i = col; i <= n; i++) {
m[j, i] = m[j, i] * p - m[col, i];
}
}
}
}
}
}
proc solve() {
gaussMatrix();
if(ratio == 0) {
return(0);
} else {
return(getDiagonal());
}
}
generateMatrix();
det(m);
solve();
exit;
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}