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

深度问题.

Posted by uni at 2005-08-31 14:37:17 on Problem 1844
In Reply To:为什么会出现G++ AC C++ RE.? Posted by:Lucifer at 2005-08-31 13:58:37
> 
> #include <memory.h>
> #include <iostream.h>
> #include <math.h>
> long n,t=0;
> bool v1[100005],v2[100005];
> int solve(long i)
> {
>         int j;
>         for (j=0;j<=t;j++)
>         {
>                 if (v1[j]==true)
>                 {
>                         v2[j+i]=true;
>                         v2[abs(j-i)]=true;
>                 }
>         }
>         if (v2[n]==true) {cout<<i<<endl; return 0;}
>         t+=i;
>         for (j=0;j<=t;j++) v1[j]=v2[j];
>         memset(v2,false,sizeof(v2));
>         solve(i+1);
>         return 0;
> }
> int main(int argc, char* argv[])
> {
>   //      while(1)
>     //    {
>         cin>>n;
>         memset(v1,false,sizeof(v1));
>         memset(v2,false,sizeof(v2));
>         v1[0]=true;
>         solve(1);
>       //  }
>         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