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

ft.....不要递归阿,多明显的重叠子问题阿,用递推

Posted by TN at 2005-04-12 12:37:46 on Problem 1953
In Reply To:怎么超时? Posted by:timonchen at 2005-04-12 08:22:01
> int fobin(int n)
> {
>     int sum;
>     if(n==1)return(2);
>     if(n==2)return(3);
>     else return(fobin(n-2)+fobin(n-1));
> }
> 
> main()
> {
>     int n,i,a[45],sum,j;
>     scanf("%d",&n);
>     for(i=1;i<=n;i++)
>         scanf("%d",&a[i]);
>     for(i=1;i<=n;i++)
>         printf("Scenario #%d:\n%d\n",i,fobin(a[i]));
> }

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