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的?小弟先谢了:)

Posted by seol at 2004-11-08 16:25:40 on Problem 1142
#include <stdio.h>
#include <math.h>

int issushu(long int k)
{
	int i=2;
	while ( (k%i!=0) && (i<1+sqrt(k)) ) i++;
	if (i>sqrt(k)) return 1;
	else return i;
}

int shuzihe(long int k)
{
	int sum=0;
	while (k>10) {
		sum+=k%10;
		k=k/10;
	}
	sum+=k;
	return sum;
}

int not(long int n)
{
	int sum1=0,yinzi,sum2=0;
	long int nn=n,mm=n;
	while (nn>9) {
		sum1+=nn%10;
		nn/=10;
	}
	sum1+=nn;
	yinzi=issushu(mm);
	if (yinzi==1) return 1;
	while (yinzi!=1) {
		sum2+=shuzihe(yinzi);
		mm=mm/yinzi;
		yinzi=issushu(mm);
	}
	sum2+=shuzihe(mm);
	if (sum1==sum2) return 0;
	else return 1;
}

int main()
{
	long int m,n;
	scanf("%ld",&m);
	n=m+1;
	while (not(n)) n++;
	printf("%ld",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