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

我已经做了好几个小时了!那位高手可以指点一下,或者给几个较大的数据吧。。。。

Posted by glaver at 2004-02-27 13:39:14 on Problem 1091
#include "stdio.h"
#include "math.h"
#define Eof -1
#define Max 200
void SubMore(int sub[],int result[])
  {
   int i,ii,add=0,add_n;
   int tmp[Max]={0};
   for(i=0;sub[i]!=Eof;i++)
      {
       if(add!=0)
          {
           tmp[add_n]+=add;
           add=0;
           }
       add_n=i;
       for(ii=0;result[ii]!=Eof;ii++)
          {
           tmp[add_n]+=sub[i]*result[ii]+add;
           add=tmp[add_n]/10;
           tmp[add_n++]%=10;
          }
      }
  tmp[add_n]+=add;
  if(add==0) tmp[add_n]=Eof;
  else       tmp[++add_n]=Eof;
  for(i=0;tmp[i]!=Eof;i++)
     result[i]=tmp[i];
  result[i]=Eof;
  }
 void Exchang(long x,int In[])
  {
   int i=0;
   while(x)
     {
      In[i++]=x%10;
      x/=10;
      }
   In[i]=Eof;
  }

void Jian(int k1[],int k2[])
  {
   int i,add=0;
   for(i=0;k1[i]!=Eof;i++)
      {
       k2[i]+=-k1[i]+add;
       add =(k2[i]+10)/10-1;
       k2[i]-=10*add;
      }
   while(add!=0)
    {
       k2[i]+=add;
       add =(k2[i]+10)/10-1;
       k2[i]-=10*add;
   }
  }

void Input(int k[])
  {
  int i=-1;
  while(k[++i]!=Eof);
  for(i--;i!=-1;i--) printf("%d",k[i]);
  printf("\n");
  }

main()
{
  int i,ii;
  int n,dev_m;
  long m;
  int num1[15];
  int num2[15];
  int result[Max],tmpp[Max];
  scanf("%d %ld",&n,&m);
  ii=sqrt(m);
  dev_m=1;
  for(i=2;i<=ii;i++)
     {
      if(m%i!=0) continue;
      dev_m++;
      if(i!=m/i) dev_m++;
      }

  Exchang(m,num1);
  Exchang(m,result);
  Exchang((long)dev_m,num2);
  Exchang((long)dev_m,tmpp);
  for(i=1;i<n;i++)
     {
     SubMore(num1,result);
     SubMore(num2,tmpp);
      }
  Jian(tmpp,result);
  Input(result);

}

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