fork(1) download
  1. #include <vector>
  2. #include <stddef.h>
  3. #include <stdio.h>
  4.  
  5. int count(int n) {
  6. std::vector<int> moves = { 3, 5, 10 };
  7. std::vector<int> c(n + 1, 0);
  8. c[0] = 1;
  9. for (int m : moves) for (size_t i = m; i <= n; ++i) c[i] += c[i - m];
  10. return c[n];
  11. }
  12. int main(void) {
  13. int n = 20;
  14. printf("Count for %d is %d\n", n, count(n));
  15.  
  16. n = 13;
  17. printf("Count for %d is %d", n, count(n));
  18. return 0;
  19. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
Count for 20 is 4
Count for 13 is 2