首页 > 试题广场 >

有20个人去看电影,电影票50元。其中只有6个人有50元钱,

[单选题]
有20个人去看电影,电影票50元。其中只有10个人有50元钱,另外10个人都只有一张面值100元的纸币,电影院没有其他钞票可以找零,问有多少种找零的方法?
  • 16796
  • 16798
  • 16794
  • 16792

深搜,一共要收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;
}
发表于 2022-01-05 17:59:47 回复(0)