Created
February 8, 2015 12:06
-
-
Save eroltutumlu/8172f85b0fb542d90a81 to your computer and use it in GitHub Desktop.
Lattice paths // Project Euler 15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define SIZE 20 | |
| //http://www.robertdickau.com/lattices.html must be known for solution. | |
| int main(void) { | |
| int i,j; | |
| long long int grid[SIZE+1][SIZE+1]; | |
| long long sum = 0; | |
| for(i=0;i<SIZE;i++) | |
| { | |
| grid[i][SIZE] = 1; | |
| grid[SIZE][i] = 1; | |
| } | |
| for(i=SIZE-1;i>=0;i--) | |
| { | |
| for(j=SIZE-1;j>=0;j--) | |
| { | |
| grid[i][j] =grid[i+1][j]+grid[i][j+1]; | |
| sum = grid[i][j]; | |
| } | |
| } | |
| printf("%lld",sum); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment