fork download
  1. #include <stdio.h>
  2.  
  3. int count_combinations(int hp) {
  4. if (hp == 0) {
  5. return 1;
  6. }
  7. if (hp < 0) {
  8. return 0;
  9. }
  10. return count_combinations(hp - 20) + count_combinations(hp - 50) + count_combinations(hp - 100);
  11. }
  12.  
  13. int main() {
  14. int T, N, i;
  15. scanf("%d", &T); // jumlah kasus uji
  16.  
  17. for (i = 0; i < T; i++) {
  18. scanf("%d", &N);
  19. int hasil = count_combinations(N);
  20. printf("%d\n", hasil);
  21. }
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 5304KB
stdin
3
100
20
150
stdout
3
1
9