相傳李白去打酒.
話說大 詩人李白去打酒,一生好飲。幸好他從不開車
一天詩人李白,他提著酒壺,從家里出發,酒壺中有酒2升,他邊走邊唱
無事街上走,提壺去打酒
逢店加一倍,遇花喝一斗
這一路上他共遇到店5次 ,花10次
一直最后一次遇到的是花,他正好把酒喝光了;
請你計算李白遇到店和花的次序,可以把遇店紀為a遇花記為b,想這樣的答案一共有多少種*/
#include<stdio.h.>
#include<string.h>
int count=0;
char a[16];
void fun(int num,int flower,int jiu,int store )
{
if(jiu<0||flower>10||store>5)
{
return ;
}
else if(num==13&&store==5&&jiu==2)
{
count++;
PRintf("%Ls/n",a);
return ;
}
else if(num<13)
{
a[num]='B';
fun(num+1,flower+1,jiu-1,store);
a[num]='A';
fun(num+1,flower,jiu*2,store+1);
}
}
int main()
{
a[15]='/0';
a[14]='B';
a[13]='A';
///a[0]=' ';
fun(0,0,2,0);
//printf("/n");
printf("%d/n",count);
return 0;
}
新聞熱點
疑難解答