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

哈哈。。用set做真是简单啊!!先是

Posted by songzi at 2008-10-04 15:57:16 on Problem 1316
由于set可以对加入的数排序,并且保证没有相同的数(multiset可以相同),所以问题就简单了。。。下面是代码(已被注释)

// #include <iostream>
// #include <set>
// 
// using namespace std;
// 
// int GetDigitsum(int a)
// {
// 	int sum=0;
// 	while (a)
// 	{	sum+=a%10;
// 	a/=10;
// 	}
// 	return sum;
// 
// }
// 
// 
// 
// int main() 
// {int i,t;
// set<int> IntSet;
// for (i=1;i<=10000;i++)
// {t=i+GetDigitsum(i);  //先是把非SelfNumber存在set里面
// IntSet.insert(t);
// }
// 
// for(i=1;i<=10000;i++)
// {if(IntSet.find(i)==IntSet.end()) 
///////////////////////利用set自带的find函数判断有没有,如果没有则输出
// cout<<i<<endl;
// }
// 
//     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