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 jinbi at 2008-10-25 19:26:02 on Problem 1152
#include<stdio.h>
#include<string.h> 

char ch[29945];
int main()
{
    int a=2,va,i; 
    while(scanf("%s",ch)!=EOF)
    {
          va=0;    a=2;
          for(i=0;i<strlen(ch);i++)
          {      if(ch[i]>='0'&&ch[i]<='9')
                 {      if(ch[i]-48>a) a=ch[i]-48;  
                        va+=(ch[i]-48);
                 }              
                 if(ch[i]>='A'&&ch[i]<='Z')
                 {      if(ch[i]-55>a) a=ch[i]-55;
                        va+=(ch[i]-55);
                 }
                 if(ch[i]>='a'&&ch[i]<='z') 
                 {      if(ch[i]-61>a) a=ch[i]-61;
                        va+=(ch[i]-61);
                 }                 
          }
          //printf("a=%d\n",a);
          for(i=a;i<=62;i++)
          {      
                 if(va%(i-1)==0) 
                 {    printf("%d\n",i);
                      break;
                 }
          }
          if(i>62) printf("such number is impossible!\n");
    }
    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