Project Euler problem 15
This commit is contained in:
@@ -1,26 +1,19 @@
|
|||||||
/* Check cf5-opt.vim defs.
|
#Lattice paths
|
||||||
VIM: let g:lcppflags="-std=c++11 -O2 -pthread"
|
#Problem 15
|
||||||
VIM: let g:wcppflags="/O2 /EHsc /DWIN32"
|
#
|
||||||
*/
|
#Starting in the top left corner of a 2x2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
|
||||||
#include <iostream>
|
#__ _ _
|
||||||
|
# | |_ | | |_ |__
|
||||||
|
# | | |_ |__ |_ |
|
||||||
|
#
|
||||||
|
#How many such routes are there through a 20x20 grid?
|
||||||
|
#
|
||||||
|
#Solution:
|
||||||
|
|
||||||
/*
|
a = 1
|
||||||
Lattice paths
|
b = 1
|
||||||
Problem 15
|
for i in range(21,41):
|
||||||
|
a *= i
|
||||||
Starting in the top left corner of a 2x2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
|
b *= i-20
|
||||||
__ _ _
|
print( a//b )
|
||||||
| |_ | | |_ |__
|
|
||||||
| | |_ |__ |_ |
|
|
||||||
|
|
||||||
How many such routes are there through a 20x20 grid?
|
|
||||||
|
|
||||||
Solution:
|
|
||||||
*/
|
|
||||||
|
|
||||||
int main ( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user