Created
June 28, 2021 15:23
-
-
Save LucaDantas/dfe0bed151d475145a685cebe60f426b to your computer and use it in GitHub Desktop.
This file contains 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 <cstdio> | |
#include <vector> | |
using namespace std; | |
int solve(vector<int> caminho, int n) { | |
int atual = caminho.back(), ans = 0; | |
if(atual + 1 <= n) { | |
caminho.push_back(atual+1); | |
ans += solve(caminho, n); | |
caminho.pop_back(); | |
} | |
if(atual + 2 <= n) { | |
caminho.push_back(atual+2); | |
ans += solve(caminho, n); | |
caminho.pop_back(); | |
} | |
if(atual == n) ++ans; | |
return ans; | |
} | |
int main() { | |
int n; scanf("%d", &n); | |
printf("%d\n", solve({1}, n)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment