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的,测试数据都过了(附Code)

Posted by RUNSLOWLY at 2008-10-09 13:40:40 on Problem 1331
In Reply To:Re:提示大家一下,这道题输出不超过36 Posted by:RUNSLOWLY at 2008-10-09 13:39:25
#include<stdio.h>
#include<math.h>
int f(int n,int m)
{
	int i,sum,j,all,k;
	i=1;
	sum=n;
	while(n/10>0)
	{
		i++;
		n=n/10;
	}
	k=0;
	for(j=0;j<i;j++)
	{
		all=sum%10;
		k+=all*(int)pow(m,j);
		sum=sum/10;
	}
	return k;
}
int main()
{
	int p,q,r,i,time;
	scanf("%d",&time);
	while(time--)
	{
		scanf("%d%d%d",&p,&q,&r);

		for(i=2;i<=36;i++)
		{
			if(f(q,i)*f(p,i)==f(r,i))
			{
				printf("%d\n",i);
				break;
			}
		}
		if(i>36)
			printf("0\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