天天看點

藍橋杯--李白打酒--深搜

#include <iostream>

using namespace std;
int ans=0;
void deepfind(int dian,int flower,int jiu){
    if(dian==0 && flower==0 && jiu==1){//最後一壺酒留給花
        ans++;
    }
    if(dian>0){//碰到店
        deepfind(dian-1,flower,jiu*2);//店減一,酒翻倍
    }
    if(flower>0){//遇到花
        deepfind(dian,flower-1,jiu-1);//花減一,酒減一
    }
}
int main()
{
    cout << "Hello world!" << endl;
    deepfind(5,9,2);
    cout << ans <<endl;
    return 0;
}

           
藍橋杯--李白打酒--深搜

繼續閱讀