Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

(C语言)看看最笨的方法,为什么不能运行?

Posted by xiao1590 at 2006-03-16 20:20:51 on Problem 1775
#include<stdio.h>
main()
{
 long int a[10]={1,1,2,6,24,120,720,5040,40320,362880,0};
 long int n;
 int numflag[409115]={0};
 int index[10];
 int i,j,breakflag=0;
 for(index[0]=0;index[0]<10;index[0]++)
    for(index[1]=0;index[1]<10;index[1]++)
        for(index[2]=0;index[2]<10;index[2]++)
            for(index[3]=0;index[3]<10;index[3]++)
                for(index[4]=0;index[4]<10;index[4]++)
                    for(index[5]=0;index[5]<10;index[5]++)
                        for(index[6]=0;index[6]<10;index[6]++)
                            for(index[7]=0;index[7]<10;index[7]++)
                                for(index[8]=0;index[8]<10;index[8]++)
                                    for(index[9]=0;index[9]<10;index[9]++)
                                        {
                                         breakflag=0;
                                         for(i=0;i<10;i++)
                                            for(j=0;j<10;j++)
                                                {
                                                 if (i==j)
                                                    continue;
                                                 if (index[i]==index[j] && index[i]!=0)
                                                    {
                                                     breakflag=1;
                                                     break;
                                                    }
                                                }
                                         if (breakflag==1)
                                            continue;
                                         numflag[a[index[0]]+a[index[1]]+a[index[2]]+a[index[3]]+a[index[4]]+a[index[5]]+a[index[6]]+a[index[7]]+a[index[8]]+a[index[9]]]=1;
                                        }
 numflag[0]=0;
 while(1)
    {
     scanf("%ld",&n);
     if (n<0)
        exit(0);
     if (numflag[n]==1)
        printf("YES\n");
     else
        printf("NO\n");
    }
}
意思是建立容量为409115的数组,来保存这个数是否符合条件,我初学,实在没别的办法,各位AC的可不可以贴个代码我学习下?谢谢!

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator