摘要:
问设有50个台阶的楼梯, 若一个人上楼梯跨出一步有三种迈法:一次上1个台阶, 一次上2个台阶, 一次上3个台阶。 问总共有多少种不同的上楼方式?考虑他迈最后一步的情况, 即最后一步上了1个台阶, 也可能上了2个台阶, 也可能上了3个台阶。Last step=1 -> 前边有(50-1) 个台阶-> 49个台阶有多少种上楼方式Last step=2 -> 前边有(50-2) 个台阶 -> 48个台阶有多少种上楼方式Last step=3 -> 前边有(50-3) 个台阶 -> 47个台阶有多少种上楼方式所以, 50个台阶情况=49个台阶的情况+48个台阶的情况 阅读全文
posted @ 2012-05-23 22:32
零点零一
阅读(349)
评论(0)
推荐(0)
摘要:
Josephus Problem C#实现:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceJosephus{classProgram{staticvoidMain(string[]args){JosephusOutput(-11,10);}staticvoidJosephusOutput(intM,intN){//Inputvalidationcheckif(M<0||N<0)return;//InitializethesequenceJosephusDa 阅读全文
posted @ 2012-05-23 21:36
零点零一
阅读(204)
评论(0)
推荐(0)
浙公网安备 33010602011771号