| ||||||||||
| 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 | |||||||||
题目规模是500000,而且500000的数组也根本不够In Reply To:求助:为什么老是runtime error呀 Posted by:00448322 at 2005-04-05 13:15:43 > #include <iostream.h>
>
> bool show[50001];
>
> void main()
> {
> int n;
> int b;
> while(1)
> {
> cin>>n;
> if(n==-1)
> break;
> if(n==0)
> { cout<<"0\n";
> continue;
> }
> if(n==1)
> { cout<<"1\n";
> continue;
> }
> if(n==2)
> { cout<<"3\n";
> continue;
> }
> for(int j=0;j<50001;j++)
> show[j]=false;
> show[0]=true;
> show[1]=true;
> show[3]=true;
> b=3;
> for(int i=3;i<=n;i++)
> {
> if(show[b-i]==false&&b-i>0)
> {
> b=b-i;
> show[b]=true;
> }
> else
> {
> b=b+i;
> show[b]=true;
> }
>
> }
> cout<<b<<endl;
> }
>
>
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator