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

Runtime Error!!!!!!!!why?????????????

Posted by zhuang000 at 2007-04-26 20:16:32 on Problem 1152
#include "stdio.h"
#include "string.h"
#include "math.h"
#define max 1000
int translate(char num)
{  int intnumber;
   if(num>='0'&&num<='9')intnumber=num-'0'; 
   else if(num>='A'&&num<='Z')intnumber=num-'A'+10;
 	    else if(num>='a'&&num<='z')intnumber=num-'a'+36;
   return intnumber;
}
int main()
{ char charnum[max];
  int r;
  int i,maxnum;
  double zong;
  int length;
  int intnum[max];
  while(scanf("%s",&charnum)==1){
      length=strlen(charnum);
      maxnum=0;
      for(i=0;i<length;i++){
          intnum[i]=translate(charnum[i]);
          if(maxnum<intnum[i])maxnum=intnum[i];
      }
      if(maxnum==0)printf("2\n");
      else {
               for(r=maxnum+1;r<=62;r++){
                  zong=0;
                  for(i=0;i<length;i++){
                     zong+=intnum[i]*pow(r,length-1-i);
                  }
                  if((int)zong%(r-1)==0)break;
               }  
               if(r==63)printf("such number is impossible!\n");      
               else printf("%d\n",r);  
            }
   }    
   return 0;
}       

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