| ||||||||||
| 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 | |||||||||
你为什么要这样用set呢?一个单个的set记录已有的数就好啦,用不着数组的In Reply To:请高手指点:我用上交的数据测了,一点问题也没有,但在pku总是wa,请指点一下 Posted by:yinsheng at 2005-04-13 11:49:07 > #include <stdio.h>
> #include <stdlib.h>
> #include <set>
> #include <vector>
> using namespace std;
> int main()
> {
> set<long> h[100000];
> long t,i,k,a;
> scanf("%d",&k);
> while (k!=-1) {
> t=0;
> for(i=0;i<100000;i++) h[i].clear();
> for(i=1;i<=k;i++)
> if ((t-i>0)&&(h[(t-i) % 100000].find(t-i)==h[(t-i) % 100000].end()))
> {
> t=t-i;
> h[t % 100000].insert(t);
> }
> else
> {
> t=t+i;
> h[t % 100000].insert(t);
> }
> printf("%d\n",t);
> scanf("%d",&k);
> }
> //system("pause");
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator