能力值:
(RANK:350 )
|
-
-
137 楼
将heXer解这个方程的代码帖份上来,真是牛人呀
#include <windows.h>
#include <stdio.h>
#include <math.h>
#define n 20
int az,bz,cz,dz,ez;
float b[n];
float l[n][n],x[n];
float a[n][n];
float aa[n+5][n+5] = {
{24861, -7743, 32344, -32179, 18082, -18373, 30399, 25827, -10897, -22044, -18411, 30275, -25423, -7376, 774, -27389, 956, -27983, -31784, -19372, 0,0,0,0,0},
{-20712, -22760, 16073, 11813, 30669, 26709, 13777, -4315, 10770, 27263, -15587, 6729, -14067, -11692, -19448, -26888, 2592, -557, 23042, 1803, 0,0,0,0,0},
{23202, -2325, -17269, 1236, 28897, 20923, -27651, 101, -25191, 8134, -18655, -29478, -26902, 2546, -407, 23532, -3403, -13748, 12734, -909, 0,0,0,0,0},
{49820, -29846, -67524, 8734, 50112, -7276, -75692, -114418, -53490, 44060, 46724, 19028, -96052, 14522, 42858, 108334, -60008, 100098, 27324, -123144, 0,0,0,0,0},
{-4881, 8922, -21229, 21072, 28137, -18441, -30177, -24620, -9999, 24977, 8121, 18613, -20107, -24736, -9620, 26214, -12161, 17916, -17831, -32169, 0,0,0,0,0},
{10430, -26153, 4992, -8395, 30215, -25227, -8016, -31452, -20456, -23596, -13342, 14060, 5239, -9201, -27583, -323, 23806, 4297, 6125, -12095, 0,0,0,0,0},
{-15488, -7052, -1832, -18879, 28746, -20429, -23685, 13052, 1947, 31219, -28505, -30080, -24936, -8967, -28347, 30596, -26471, 3954, 5005, 8437, 0,0,0,0,0},
{-32509, 17004, 14853, 7829, -17659, -32730, 16283, -12499, 16813, 14229, -5791, 5950, -11523, 20000, 24637, -7011, 1966, -31281, 21015, 27951, 0,0,0,0,0},
{-24132, -11592, -19775, -25820, -6080, 5006, -8441, 30064, 24733, 7325, 16013, 11617, 30029, -24619, 10002, 24755, 7397, -16249, 4567, 7007, 0,0,0,0,0},
{-77624, -75332, 46387, 16560, 120753, 59698, 17646, 107, 34257, 113008, -75266, -9893, -67137, -44043, -86691, -50068, -18695, 2283, 74131, 13846, 0,0,0,0,0},
{12405, 32603, -257, 24022, 5003, 8431, -19625, -26310, 4480, -6723, -2907, 15368, -9511, -26570, -3631, 13004, -1791, -19012, -28312, 30710, 0,0,0,0,0},
{29791, -23845, -12533, -16705, -3081, 14803, -7669, -32589, -16746, -2947, 15241, -9099, -27919, 31997, 31049, 27953, -17843, 32133, 31493, -29403, 0,0,0,0,0},
{32204, 31725, -30161, 24675, 7139, -15409, -7313, -983, 21654, -30041, 25067, 8419, -19589, 26431, -12873, 15595, 10255, -25585, 6851, -14469, 0,0,0,0,0},
{7823, 17643, 16943, -14657, -9769, 25731, 10587, -26669, 3311, -2909, -15365, -7457, -513, -23189, 14675, 7251, 15775, 10843, -27505, -581, 0,0,0,0,0},
{-16130, -4959, 8670, -20409, -23753, -12833, -15725, 6281, -12607, -16463, 3871, 4737, -7565, 160, -25387, -7497, -382, -23617, 13277, -2685, 0,0,0,0,0},
{55421, 91735, -79249, 77943, 34211, -6397, -8317, -14665, 27145, -64933, 41111, -11329, -70365, 74187, -54713, 59764, 40381, -26951, 8053, -35355, 33816113},
{-50618, 130767, -134388, -53818, 74319, -33166, -110627, -98646, 39464, -97256, -109540, 51572, -104032, 133789, -172490, 93234, 109010, -51138, -129070, -103954, 0,0,0,0,0},
{5731, 10811, 27401, -16041, 5249, 9237, 22261, -32023, -18595, 29677, 23473, 3213, 2589, -551, 23065, 1881, -31007, 21913, -30887, -22304, 0,0,0,0,0},
{-26392, 4215, -5861, -5725, -6169, 4719, 7507, 16611, -13573, -13309, 14171, -5605, -6561, 3439, 3327, -2961, 15195, -8949, -28409, -30397, 0,0,0,0,0},
{17466, -16365, -4191, 11178, 28599, -19953, -25242, -7971, 31602, 29759, -23741, 12872, 1363, 29315, 22291, -32121, 18275, 19007, -21397, 20527, 0,0,0,0,0},
{28640, -20087, 24805, -7563, -167, -24319, 10985, 27969, -17895, -31963, -18791, 29037, -21383, -20572, -23221, -14570, 10053, 24925, -7955, -31655, 0,0,0,0,0},
{-8559, 29682, -23489, -13695, 12910, -1487, -20008, -25063, 8555, -20033, -24981, 8823, -20909, 22120, -31563, 20097, 24957, -8059, -31315, -20907, 0,0,0,0,0},
{25559, -89270, -12425, -9144, 85396, -84918, -46309, -62333, -42773, -100465, -63499, 38967, 13128, -27052, -105814, -2850, 102425, -9022, 49262, -13981, 0,0,0,0,0},
{-28181, -31141, 21475, 29457, 22755, -869, 22027, 31259, 28639, 20083, 24911, -7909, -31805, 19307, -22377, 17327, 15911, 11287, 28955, 21115, 0,0,0,0,0},
{-8987, 28285, -18927, 28593, 19933, 24421, 6309, -12699, -16163, -4851, -9023, -28167, -31187, 21325, -28967, 28574, 19871, 24219, -5649, -6417, 0,0,0,0,0}
};
float bb[n+5] = {-121683, 1504646, -2946186, -1186958, -6867922, -9344860, -9620610, 1926374, 979553, -5160672, -1603989, 935443, 1620348, 1823579, -12408329, 33816113, -6102129, 4566102, -3403914, 6001704, -2142312, -11839530, -3260082, 10541251, 140917};
int fk()
{
int i,j,k,on,m,T,temp;
on=0;
for (k=0;k<n;k++)
{
T=k;
for (m=k+1;m<n;m++)
{
if(fabs(a[T][k])<fabs(a[m][k]))
{
T=m;
}
if (T!=k)
{
for (m=k;m<n;m++)
{
temp=a[k][m];
a[k][m]=a[T][m];
a[T][m]=temp;
}
temp=b[T];b[T]=b[k];b[k]=temp;
}
}
if (a[k][k]==0&&k!=n-1)
{
//printf("erro! eixt\n");
on=1;
}
if (a[k][k]!=0)
{
for (i=k+1;i<n;i++)
{
l[i][k]=a[i][k]/a[k][k];
b[i]=b[i]-l[i][k]*b[k];
for (j=k+1;j<n;j++)
{
a[i][j]=a[i][j]-l[i][k]*a[k][j];
}
}
}
}
if (a[n-1][n-1]==0)
{
//printf("没有唯一解\n");
on=1;
}
if (on==0)
{
x[n-1]=b[n-1]/a[n-1][n-1];
for (i=n-2;i>=0;i--)
{
x[i]=b[i];
for (j=i+1;j<n;j++)
x[i]=x[i]-a[i][j]*x[j];
x[i]=x[i]/a[i][i];
}
for (i=0;i<n;i++)
{
if ((x[i]<0) || (x[i]>255))
{
on = 1;
}
}
if (on == 0)
{
printf("exclude lines:%d,%d,%d,%d,%d\n",ez+1,dz+1,cz+1,bz+1,az+1);
for (i=0;i<n;i++)
{
printf("x[%d]= %f ",i+1,x[i]);
if (i%4==3)
printf("\n");
}
printf("\n");
//getchar();
}
}
return 0;
}
int main()
{
int i,j,l;
for (az=0;az<n+5;az++)
{
for (bz=0;bz<az;bz++)
{
for (cz=0;cz<bz;cz++)
{
for (dz=0;dz<cz;dz++)
{
for (ez=0;ez<dz;ez++)
{
i=0;
for (l=0;l<n+5;l++)
{
if ((l==az)||(l==bz)||(l==cz)||(l==dz)||(l==ez))
{
continue;
}
for (j=0;j<n;j++)
{
a[i][j] = aa[l][j];
}
b[i] = bb[l];
i++;
}
fk();
}
}
}
}
}
return 0;
}
|