#include<bits/stdc++.h>
using namespace std;
char sz[151];//存放排好的字母
int che[100];//存放连续字母的个数
int ans=0;//答案
void dfs(int step, int r, int g, int b);//深搜
bool check();//检查是否为递增
int main()
{
int r,g,b;
cin>>r>>g>>b;
dfs(0,r,g,b);
cout<<ans<<endl;
return 0;
}
void dfs(int step, int r, int g, int b)
{
if (r==0 && g==0 && b==0)
{
if (check())
{
ans++;
}
return;
}
if (r!=0)
{
sz[step]='r';
dfs(step+1,r-1,g,b);
}
if (g!=0)
{
sz[step]='g';
dfs(step+1,r,g-1,b);
}
if (b!=0)
{
sz[step]='b';
dfs(step+1,r,g,b-1);
}
}
bool check(){
int cnt = 1;
int t = 0;
for(int i=0;sz[i];i++){
if(sz[i]==sz[i+1]){
cnt++;
}else{
che[t++] = cnt;
cnt = 1;
}
}
for(int i=1;i<t;i++){
if(che[i]<=che[i-1]){
return false;
}
}
return true;
}
排列小球(DFS)
最新推荐文章于 2023-09-17 12:46:30 发布