| ||||||||||
| 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 | |||||||||
ft.....不要递归阿,多明显的重叠子问题阿,用递推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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator