siflaneur / algorithms Goto Github PK
View Code? Open in Web Editor NEW📌《程序员的算法趣题》——Python 解法
📌《程序员的算法趣题》——Python 解法
"""
#背景:A上楼梯时,B 从同一楼梯往下走。每次不一定只走 1 级,最多可 以一次跳过 3 级(即直接前进 4 级)。 但无论走多少级,1 次移动所需时间不变。两人同时开始走,求共 B
有多少种“两人最终同时停在同一级” 的情况(假设楼梯宽度足够,可以相互 错开,不会撞上。另外,同时到达同一
级时视为结束)。
#问题:求当存在 10 级楼梯,且移动规则相同时,有多少种两人最终同时停在同一 级的情况?
"""
这题我怎么也算不出来能走201步:
我的走法如下:一共才14步。
步,走一步,次数,上下走的步数。
|1 | 1| 1 : <1> + <9>
|2 | 1| 2 : <2> + <8>
|3 | 1| 3 : <3> + <7>
|4 | 1| 4 : <4> + <6>
|5 | 1| 5 : <5> + <5>
|6 | 1| 6 : <6> + <4>
|7 | 1| 7 : <7> + <3>
|8 | 1| 8 : <8> + <2>
|9 | 1| 9 : <9> + <1>
|10 | 2| 1 : <2> + <8>
|11 | 2| 2 : <4> + <6>
|12 | 2| 3 : <6> + <4>
|13 | 2| 4 : <8> + <2>
|14 | 5| 1 : <5> + <5>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.