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

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

Posted by cuiwj871128 at 2008-11-15 20:16:14 on Problem 1316
In Reply To:哈哈。。用set做真是简单啊!!先是 Posted by:songzi at 2008-10-04 15:57:16
> 由于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;
> // }
> 
> 
> 
似乎用vector也可以到这种效果呢

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