遞迴_找錢的排列組合

user_3763047219 avatar
user_3763047219
c_cpp
01/04/2023 7:39 PM
504 B
19
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...