hdu-1261

字符串,本来想的这道题很简单

#include
#include
int len,a[1000];
void  jiecheng(int n)
{
  int i,j,temp,carry;                   
  a[0]=1;
  len=1;     
  for(i=2;i<=n;i++)
  {
    carry=0;
    for(j=0;j      {
       temp=a[j]*i+carry;                                  
       a[j]=temp%10000;
       carry=temp/10000;             
     }
     if(carry)
       a[len++]=carry;
  }   
}
int main()
{
    int i,j,k,n,temp;
    int sum,num[26],carry;
    while(~scanf("%d",&n),n!=0)
    {
      sum=0;
      for(i=0;i       {
        scanf("%d",&num[i]);
        sum+=num[i];           
      } 
      jiecheng(sum);
       for(i=0;i        {
        
         for(j=2;j<=num[i];j++)
         {
           carry=0;
           for(k=len-1;k>=0;k--)
           {
              temp=a[k]+carry*10000;   
              a[k]=temp/j;                                                          
              carry=temp%j;
           }
            if(a[len-1]==0) len--;    
         }                                  
       }    
       printf("%d",a[len-1]);
       for(i=len-2;i>=0;i--)
       printf("%04d",a[i]);
       printf("\n");                  
    }
return 0;   
}

你可能感兴趣的:(hdu习题,大数)