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

Please give me some sample tests. Thanks!

Posted by yogafrank at 2007-09-15 19:27:57 on Problem 1152
# include <stdio.h>
# include <string.h>

char digits[32800];

main ()
{
	int i;
	int base = 0, value = 0, flag = 0;

	while (scanf ("%s", digits) != -1)
	{
		for (i = 0; i < strlen (digits); i++)
		{
			if (digits[i] > base)
				base = digits[i];
			if (base >= '0' && base <= '9')
		    	value += digits[i] - '0';
	    	else if (base >= 'A' && base <= 'Z')
		    	value += digits[i] - 'A' + 10;
	    	else
		    	value += digits[i] - 'a' + 36;
		}

		if (base >= '0' && base <= '9')
			base = base - '0' + 1;
		else if (base >= 'A' && base <= 'Z')
			base = base - 'A' + 11;
		else
			base = base - 'a' + 37;

		while (base <= 62)
		{
			if (value % (base - 1) == 0)
			{
				flag = 1;
				break;
			}
			base++;
		}

		if (flag == 1)
		{
			printf ("%d\n", base);
			flag = 0;
		}
		else
			printf ("such number is impossible!\n");
		base = 2;
		value = 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