麻烦各位,看一下下面这个程序
#include <stdio.h>#include <stdlib.h>
#define m 14
#define n (1<<m)
int t;
int FinEleExptoVec[n-1]={0};
int TrueTab[n/2];
int IsPrimePol()
{
int PrimePol;
switch (m)
{
case 3: PrimePol=(1<<1)+1; break;
case 4: PrimePol=(1<<1)+1; break;
case 5: PrimePol=(1<<2)+1; break;
case 6: PrimePol=(1<<1)+1; break;
case 7: PrimePol=(1<<1)+1; break;
case 8: PrimePol=(1<<6)+(1<<5)+(1<<1)+1; break;
case 9: PrimePol=(1<<4)+1; break;
case 10: PrimePol=(1<<3)+1; break;
case 11: PrimePol=(1<<2)+1; break;
case 12: PrimePol=(1<<7)+(1<<4)+(1<<3)+1; break;
case 13: PrimePol=(1<<4)+(1<<3)+(1<<1)+1; break;
case 14: PrimePol=(1<<12)+(1<<11)+(1<<1)+1; break;
case 15: PrimePol=(1<<1)+1; break;
case 16: PrimePol=(1<<5)+(1<<3)+(1<<2)+1; break;
case 17: PrimePol=(1<<3)+1; break;
case 18: PrimePol=(1<<7)+1; break;
case 19: PrimePol=(1<<6)+(1<<5)+(1<<1)+1; break;
case 20: PrimePol=(1<<3)+1; break;
case 21: PrimePol=(1<<2)+1; break;
case 22: PrimePol=(1<<1)+1; break;
case 23: PrimePol=(1<<5)+1; break;
case 24: PrimePol=(1<<4)+(1<<3)+(1<<1)+1; break;
case 25: PrimePol=(1<<3)+1; break;
case 26: PrimePol=(1<<8)+(1<<7)+(1<<1)+1; break;
case 27: PrimePol=(1<<8)+(1<<7)+(1<<1)+1; break;
case 28: PrimePol=(1<<3)+1; break;
case 29: PrimePol=(1<<2)+1; break;
}
return PrimePol;
}
void Generate_FiniteFields_ExptoVec()
{
int i,PrimePol;
PrimePol=IsPrimePol();
FinEleExptoVec[0]=1;
for (i=1;i<n-1;i++)
{
if((FinEleExptoVec[i-1]>>(m-1))&1)
FinEleExptoVec[i]=((FinEleExptoVec[i-1]<<1)&(n-1))^PrimePol;
else FinEleExptoVec[i]=(FinEleExptoVec[i-1]<<1)&(n-1);
}
}
int weight(int i)
{
int k=0,j,l=i;
for(j=0;j<m;j++)
{
k=k+(l&1);
l=l>>1;
}
return k;
}
void Generate_BoolFun()
{
int i;
t=0;
for(i=0;i<n/2-3;i++)
TrueTab[t++]=FinEleExptoVec[i];
TrueTab[t++]=FinEleExptoVec[n/2-3];
TrueTab[t++]=FinEleExptoVec[n/2-2];
TrueTab[t++]=FinEleExptoVec[n/2-1];
}
int Contain(int i,int j)
{
int k;
for(k=0;k<m;k++)
if(((i>>k)&1)>((j>>k)&1))
break;
if(k==m) return 1;
else return 0;
}
void main()
{
int i,j,k,s,WeiDis[m+1][n/2]={0},Num[m+1]={0};
Generate_FiniteFields_ExptoVec();
Generate_BoolFun();
for(i=1;i<n;i++)
WeiDis[weight(i)][Num[weight(i)]++]=i;
for(i=m-1;i>0;i--)
{
for(j=0;j<Num[i];j++)
{
s=0;
for(k=0;k<t;k++)
if(Contain(TrueTab[k],WeiDis[i][j]))
s++;
if(s%2!=0)
{
printf("the algebraic degree is %d\nthe highest term is %d\n",i,WeiDis[i][j]);
break;
}
}
if(s%2!=0) break;
}
}
为什么m<15可以跑出结果,而m>=15却跑不了?
[ 本帖最后由 shanjy 于 2010-9-20 16:01 编辑 ]