文章分类 -  递推 && 递归

摘要:截取的大神们的代码分析!!!(不过超时,有待优化,数组?!?!?!)/* 解题分析: 设f(m,n) 为m个苹果,n个盘子的放法数目,则先对n作讨论, 当n>m:必定有n-m个盘子永远空着,去掉它们对摆放苹果方法数目不产生影响。即if(n>m) f(m,n) = f(m,m) 当nm时,我们会return f(m,m) 所以终会到达出口m==0.*/#includeint fun(int m,int n) //m个苹果放在n个盘子中共有几种方法{ if(m==0||n==1) //因为我们总是让m>=n来求解的,所以m-n>=0,所以让m=0时候结束,如果改为m=1, 阅读全文
posted @ 2014-04-10 21:12 我喜欢旅行 阅读(115) 评论(0) 推荐(0)
摘要:FlagTime Limit: 1000MS Memory limit: 65536K题目描述On the Day of the Flag of Russia a shop-owner decided to decorate the show-window of his shop with textile stripes of white, blue and red colors. He wants to satisfy the following conditions:1.Stripes of the same color cannot be placed next to each othe 阅读全文
posted @ 2014-04-10 20:48 我喜欢旅行 阅读(102) 评论(0) 推荐(0)