Skip to content

Instantly share code, notes, and snippets.

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 lapla-cogito/98afc076a12bc483340af7659afb5f98 to your computer and use it in GitHub Desktop.
Save lapla-cogito/98afc076a12bc483340af7659afb5f98 to your computer and use it in GitHub Desktop.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>
using std::endl;
using std::string;
#define ll long long int
#define LEP(a, n) for(ll a = 0; a < n; ++a)
#define INF 123456789012345
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std
ll N;
ll recurse(ll state, ll length, ll startN) {
if (length == 0 && state == 0) return 1;
if (length == 0 && state != 0) return 0;
if (state < 0) return 0;
if (startN > 0) return recurse(state + 1, length - 1, startN - 1) + recurse(state - 1, length - 1, startN);
else if (state - length == 0) return 1;
else return 0;
}
int main() {
IN >> N;
OUT << recurse(0, N * 2, N) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment