Created
May 29, 2018 05:29
-
-
Save jwon0615/0fb43f3d843d0a1f24a9bd47d9744a2c 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 <stdio.h> | |
int n,sum; | |
void dfs(int k, int p1, int p2){ | |
if(k>n) return; | |
if(k==n) { | |
sum++; return; | |
} | |
if((p1==3) or (p2==3)){ | |
dfs(k+1,p2,1); | |
dfs(k+2,p2,2); | |
} | |
else{ | |
dfs(k+1,p2,1); | |
dfs(k+2,p2,2); | |
dfs(k+3,p2,3); | |
} | |
} | |
int main(){ | |
scanf("%d", &n); | |
dfs(0,0,0); | |
printf("%d", sum); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment