题目:Starting in the top left corner of a 22 grid, there are 6 routes (without backtracking) to the bottom right corner.
How many routes are there through a 2020 grid?
a=Array.new(21){Array.new(21)}
for i in 1..20
a[0][i]=1
a[i][0]=1
end
1.upto(20) do |i|
1.upto(20) do |j|
a[i][j]=a[i-1][j]+a[i][j-1]
end
end
p a
看看下面的表格:
其实就是杨辉三角嘛
分享到:
相关推荐
15. Google's private network connects together all its data centers, big and small. Traffic between the Google data centers passes over its private network rather than over the public Internet. Many ...
AIX AN15官方培训教材 教师版 AN15-Power Systems for AIX III Advanced Administration and Problem Determination
2 Hilbert's Tenth Problem 15 3 The Equivalence Problem for LOOP(1)- and LOOP(2)-Programs 25 4 The Second LBA Problem 37 5 LOGSPACE, Random Walks on Graphs, and Universal Traversal Sequences 41 6 ...
Chapter 15. Software Tool Development Illustration Chapter 16. Software Tools for Correct Program Development Part 5 Computer Operation by Problem Solving Process Chapter 17. Using First Computers to...
15PuzzleProblem
Title: Artificial Intelligence and Problem Solving Author(s): Danny Kopec, Christopher Pileggi, David Ungar, Shweta Shetty Publisher: Mercury Learning & Information Year: 2017 Language: english ...
0-1-knapsack-problem-master (15)c.zip
Chapter 15. Recursion. Chapter 16. Searching and Sorting. Chapter 17. Linked Lists. Chapter 18. Stacks and Queues. Appendix A. Reserved Words. Appendix B. Operator Precedence. Appendix C. Character ...
CHAPTER 15: ALGORITHM DESIGN TECHNIQUES CHAPTER 16: BRUTE FORCE ALGORITHM CHAPTER 17: GREEDY ALGORITHM CHAPTER 18: DIVIDE-AND-CONQUER, DECREASE-AND-CONQUER CHAPTER 19: DYNAMIC PROGRAMMING CHAPTER 20: ...
Java, Java, Java, Object-Oriented Problem Solving (3rd Edition) 3rd Edition by Ralph Morelli (Author), Ralph Walde (Author) ...15. Sockets and Networking. 16. Data Structures: Lists, Stacks, and Queues.
本篇论文针对 ZigBee Wireless Networks 中的孤立节点问题,提出很好的解决方案。
C++ Programming: From Problem Analysis to Program Design By 作者: D. S. Malik ISBN-10 书号: 1337102083 ISBN-13 书号: 9781337102087 Edition 版本: 8 出版日期: 2017-02-13 pages 页数: 1491 Contents ...
Designing an efficient algorithm to solve a computer science problem is a skill of Computer programmer. This is the skill which tech companies like Google, Amazon, Microsoft, Adobe and many others ...
Java, Java, Java, Object-Oriented Problem Solving (3rd Edition) 3rd Edition by Ralph Morelli (Author), Ralph Walde (Author) ...15. Sockets and Networking. 16. Data Structures: Lists, Stacks, and Queues.
html登录注册页面
The 2014 Benelux Algorithm Programming Contest Problem Set. BAPC2014题目。
Give a divide and conquer algorithm for the following problem: you are given two sorted lists of size m and n, and are allowed unit time access to the ith element of each list. Give an O(lg m + lgn) ...
Publication Date: 2015-05-15 ISBN-10: 1484201582 ISBN-13: 9781484201589 C++ Recipes: A Problem-Solution Approach is a handy code cookbook reference guide that cover the latest C++ 14 as well as some ...