深搜,一共要收20张票,five是已收50元的数量,step是现在到第几个人。
#include using namespace std; int ans=0; void dps(int step,int five) { if (five == 10) { ++ans; return; } dps(step + 1,five+1); if (step < five * 2) { dps(step + 1,five); } } int main() { dps(0, 0); cout << ans << endl; }