• Home
  • About
    • Moon photo

      2019 OSS E4

      E4 is a team which is made in OSS Class in 2019 1st Semester

    • Learn More
    • Twitter
    • Facebook
    • Instagram
    • Github
    • Steam
  • Posts
    • All Posts
    • All Tags
  • Projects

Project Euler Prob.15

11 Jun 2019

Reading time ~1 minute

Problem

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. How many such routes are there through a 20X20 grid?

Sol. 1

#include <stdio.h>
using namespace std;
int main()
{
	long long arr[22][22];
	for (int i = 1; i <= 21; i++)
	{
		arr[i][1] = 1;
		arr[1][i] = 1;
	}
	for (int i = 2; i <= 21; i++)
	{
		for (int j = 2; j <= 21; j++)
			arr[i][j] = arr[i - 1][j] + arr[i][j - 1];
	}
	printf("%lld", arr[21][21]);
}


Project Euler Share Tweet +1