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

wwaaaaaaaaaaaa -post program,have a see,please

Posted by mathsoft at 2006-04-21 18:00:19 on Problem 1152
#include<stdio.h>
#include<string.h>
int main()
{
 int i,j,n,max;
 long sum;
 char aa[100000];
 int a[100000];
 while(scanf("%s",aa)!=EOF)
 {
  n=strlen(aa);
  for(i=0;i<n;i++)
  {if(aa[i]>='0'&&aa[i]<='9') a[i]=aa[i]-'0';
   else if(aa[i]>='A'&&aa[i]<='Z') a[i]=aa[i]-'A'+10;
   else a[i]=aa[i]-'a'+36;
  }
  max=0;
  for(i=0;i<n;i++) 
  if(a[i]>max) max=a[i];
  for(i=2;i<=62;i++)
  { 
    sum=i*a[0]+a[1];
    for(j=2;j<n;j++)    
      sum=i*sum+a[j];
    if(sum%(i-1)==0&&i>max) {printf("%d\n",i);break;}
  }
  if(i==63) printf("such number is impossible!"\n);
 }
}

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