Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Created September 15, 2018 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save completejavascript/ccde13f040b60ac7db007bc13f762f89 to your computer and use it in GitHub Desktop.
Save completejavascript/ccde13f040b60ac7db007bc13f762f89 to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
int R, C;
int Matrix[7][7];
int Num_path;
void Visit(int row, int col)
{
// Nếu đi được đến điểm đích thì tăng số đường lên 1
if(row == R-1 && col == C-1) Num_path++;
else
{
// Nếu sang bên phải
if(row + 1 <= R-1) Visit(row + 1,col);
// Nếu đi xuống dưới
if(col + 1 <= C-1) Visit(row,col + 1);
}
}
int main()
{
int Testcase;
cin >> Testcase;
for(int tc = 0; tc < Testcase; tc++)
{
cin >> R >> C;
Num_path = 0;
Visit(0, 0);
cout << Num_path << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment