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:疯了疯了,怎么总是RE!

Posted by butterfly at 2006-09-19 12:29:47 on Problem 2081
In Reply To:疯了疯了,怎么总是RE! Posted by:Manio at 2006-09-19 11:56:09
> #include <iostream>
> using namespace std;
> #define RSIZE 50000000
> #define ASIZE 5000000
> int main()
> {
>     bool rec[RSIZE];
>     long a[ASIZE];
>     long i;
>     for (i=0;i<RSIZE;i++)
>         rec[i]=false;
>     for (i=0;i<ASIZE;i++)
>         a[i]=0;
>     a[0]=0;
>     for (i=1;i<ASIZE;i++)
>     {
>         a[i]=a[i-1]-i;
>         if(a[i]<=0 || rec[a[i]]==true)
>                    a[i]=a[i-1]+i;
>         rec[a[i]]=true;
>     }
>     long n;
>     while(cin>>n)
>     {
>                  if(n==-1)return 0;
>                  cout<<a[n]<<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