Created
May 29, 2018 05:01
-
-
Save jwon0615/fed1ad8613735eeba2e2183826629fae 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> | |
#include <queue> | |
using namespace std; | |
queue<int> q; | |
int n,sum,d; | |
void dfs(int k){ | |
if(k>n) return; | |
if(k==d) return; | |
if(k==n) { | |
sum++; return; | |
} | |
dfs(k+1); | |
dfs(k+2); | |
dfs(k+3); | |
} | |
void bfs(int k) { | |
q.push(k); | |
while(!q.empty()){ | |
int nx=q.front(); | |
q.pop(); | |
if(nx<n){ | |
q.push(nx+1); | |
q.push(nx+2); | |
} | |
else if(nx==n) sum++; | |
} | |
} | |
int main(){ | |
scanf("%d %d", &n, &d); | |
dfs(0); | |
printf("%d", sum); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment