遞迴_找錢的排列組合
user_3763047219
c_cpp
3 years ago
376 B
8
Indexable
extern int moneyPerm(int K);
int moneyPerm(int K) {
if (K >= 10) {
return moneyPerm(K - 10) + moneyPerm(K - 5) + moneyPerm(K - 1);
}
else if (K >= 5) {
return + moneyPerm(K - 5) + moneyPerm(K - 1);
}
else {
return 1;
}
}
#include <stdio.h>
int main() {
int money;
scanf("%d", &money);
printf("%d", moneyPerm(money));
return 0;
}Editor is loading...