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

大侠门帮我看看吧! 我都wa n+1次了

Posted by huanghaoxiang at 2009-07-13 16:39:11 on Problem 1152
#include <stdio.h>
#include <math.h>

int main()
{
	int i,k,j;
	char s1[30000];
	int s2[30000];
	while ( scanf ( "%s",s1 ) != EOF )
	{
		char *p1 = s1;
		int max = 0;
		for ( j = 0; *p1 != '\0'; ++p1,++j )
		{
			if ( *p1 >= '0' && *p1 <= '9' )
				s2[j] = *p1 - '0';
			else if ( *p1 >= 'A' && *p1 <= 'Z' )
				s2[j] = 10 + (*p1 - 'A');
			else  if( *p1 >= 'a' && *p1 <= 'z'  )
				s2[j] = 36 + ( *p1 - 'a' );
			if ( s2[j] > max )
				max = s2[j];
		}
		long sum;
		for ( i = max+1; i <= 62; ++i )
		{
			sum = 0;
			for ( k = 0; k < j; ++k  )
				sum=sum*i+s2[k];
			if ( sum % ( 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