Untitled

 avatar
unknown
c_cpp
3 years ago
782 B
9
Indexable
#include<stdio.h>

int n,condition,ans;
//int out[1000];
/*
void print(int length){
	for(int i=0;i<length;i++){
		printf("%d ",out[i]);
	}
	printf("\n");
}
*/
void dfs(int nowTimes, int rWin, int bWin, int rTotal, int bTotal){
	if(rWin==condition){
		ans++;
		//print(nowTimes);
		return;
	}
	if(bWin==condition){
		return;
	}
	if(nowTimes==n){
		if(rTotal>=bTotal){
			ans++;
			//print(nowTimes);
		}
		return;
	}

		dfs(nowTimes+1, rWin+1, 0, rTotal+1, bTotal);
		dfs(nowTimes+1, 0, bWin+1, rTotal, bTotal+1);
	return;
}

int main(){
	
	scanf("%d%d",&n,&condition);
	ans=0;
	dfs(0,0,0,0,0);
	printf("%d\n",ans);
	
	/*
	int k;
	scanf("%d",&k);
	for(int i=1;i<=k;i++){
		for(int j=1;j<=i;j++){
			ans=0;
			n=i;
			condition=j;
			dfs(0,0,0,0,0);
			printf("%d,",ans);
		}
	}
	*/
}
Editor is loading...