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 wpolly at 2007-06-15 06:16:25 on Problem 1331
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char a[9], b[9], c[9], tmp[9];
int main()
{
	int n, x, y, z, m;
	scanf("%d", &n);
	while (n--) {
		scanf("%s %s %s", a, b, c);
		m = 1;
		while (++m < 17) {
			x = strtol(a, NULL, m);
			y = strtol(b, NULL, m);
			z = strtol(c, NULL, m);
			if (x * y != z)
				continue;
			if (strcmp(a, itoa(x, tmp, m)))
				continue;
			if (strcmp(b, itoa(y, tmp, m)))
				continue;
			if (strcmp(c, itoa(z, tmp, m)))
				continue;
			break;
		}
		printf("%d\n", m < 17 ? m : 0);
	}
	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