日期:2014-05-17 浏览次数:20925 次
static Dictionary<int, int> dic = new Dictionary<int, int>(); private static int Test(int n) { if(!dic.ContainsKey(1)) { dic.Add(1, 1); } if (!dic.ContainsKey(2)) { dic.Add(2, 1); } for (int i = 3; i <= n; i++) { if (!dic.ContainsKey(i)) { dic[i] = dic[i - 1] + dic[i - 2]; } } return dic[n]; }