Solution to Problem 15 on ProjectEuler.net

The problem:

——-
Starting in the top left corner of a 22 grid, there are 6 routes (without backtracking) to the bottom right corner.

p_015

How many routes are there through a 2020 grid?
——-

My Solution

#include <stdio.h>

int main(){
  int i,j,x,y;
  long long int mat[21][21]; 

  i=0;
  for (j=0;j<21;j++) 
    mat[i][j]=1; 

  j=0;
  for (i=0;i<21;i++)
    mat[i][j]=1; 

  for (i=1;i<21;i++)
    for (j=1;j<21;j++)
      mat[i][j]=mat[i-1][j]+mat[i][j-1]; 

  for (i=0;i<21;i++){
    for (j=0;j<21;j++)
      printf("%lld ",mat[i][j]); 
    printf("n");
    }

  return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>