Andrewzdm @ 2021-09-30 18:59:32
WA#2
显示Too short on line 1
,为什么啊……
//P2455
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
const int maxn = 50;
const double eps = 1e-5;
double a[maxn][maxn];
int n;
int main()
{
cin >> n;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n + 1; ++j)
cin >> a[i][j];
int cur = 1, pos;
for(int i = 1; i <= n; ++i)
{
pos = cur;
for(int j = cur + 1; j <= n; ++j)
if(fabs(a[j][i]) > fabs(a[pos][i]))
pos = j;
if(fabs(a[pos][i]) < eps)
continue;
for(int j = 1; j <= n + 1; ++j)
swap(a[cur][j], a[pos][j]);
for(int j = 1; j <= n; ++j)
{
if(j == cur) continue;
double tmp = a[j][i] / a[cur][i];
a[j][i] = 0;
for(int k = i + 1; k <= n + 1; ++k)
a[j][k] -= a[cur][k] * tmp;
}
++cur;
}
if(cur <= n)
{
bool flag = true;
for(int i = cur; i <= n; ++i)
if(fabs(a[i][n + 1]) > eps)
{
flag = false;
break;
}
puts(flag ? "0" : "-1");
}
else for(int i = 1; i <= n; ++i)
printf("x%d=%.2lf\n", i, a[i][n + 1] / a[i][i]);
return 0;
}
猜测可能是因为本该输出解的情况输出了
by code_hunter @ 2021-10-02 19:21:42
请您把 maxn 修改为 51
by code_hunter @ 2021-10-03 08:08:26
阿不!52。
by Andrewzdm @ 2021-10-03 18:29:00
不知道怎么的就把maxn打成50了……
此帖终。