Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求测试数据!!!试了找到的所有数据都可以通过但还是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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator