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 adetwo at 2010-07-15 10:54:59 on Problem 1142 and last updated at 2010-07-15 10:55:39
试了找到的所有数据都可以通过但还是WA,求高手给些变态的数据,不胜感激!

#include<iostream>
#include<cmath>
using namespace std;

int Calculate(int num)
{
	int sum=0;
	while(num)
	{
		sum+=num%10;
		num/=10;
	}
	return sum;
}

int main()
{
//	freopen("output.txt","w",stdout);
	int i,num,sum1,sum2,j,curnum;
	cin>>num;
	while(num)
	{
		for(j=num+1;true;j++)
		{
			sum1=Calculate(j);
			sum2=0;
			curnum=j;
			i=2;
			while(i<=sqrt((double)curnum))
			{
				if(curnum%i==0)
				{
					sum2+=Calculate(i);
					curnum=curnum/i;
					i=2;
				}
				i++;
			}
			if(sum2)
			{
				sum2+=Calculate(curnum);
			}
			if(sum1==sum2)
			{
				cout<<j<<endl;
				break;
			}
		}
		cin>>num;

	}
	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