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 |
Re:ft.....不要递归阿,多明显的重叠子问题阿,用递推In Reply To:ft.....不要递归阿,多明显的重叠子问题阿,用递推 Posted by:TN at 2005-04-12 12:37:46 #include<iostream.h> int main(){ int m,n,v0=1,v1=1,t=1; cin>>m; for(int i=1;i<=m;i++){ cin>>n; for(int j=2;j<=n;j++){ t=v1;v1=v0;v0=t+v0;} cout<<"Scenario #"<<i<<':'<<endl; cout<<(v0+v1)<<endl<<endl; v0=1;v1=1; } } 这样也行的 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator