ProgrammingVery hardGATE CS · Campus placements
How many ordered ways are there to write 10 as a sum of parts equal to 1, 3 or 4, where the order of the parts matters?
- A. 64
- B. 55
- C. 49
- D. 81
Correct answer: A. 64
Let f(n) = f(n-1) + f(n-3) + f(n-4) with f(0) = 1. The values run 1, 1, 1, 2, 4, 6, 9, 15, 25, 40, 64, so f(10) = 64.
More C Programming questions
- int arr[10]; What is sizeof(int[10]) / sizeof(int)?
- What does printf("%d", 10 / 3 3 == 10) print?
- int x = 3; printf("%d", x << 2 | x >> 1); What is printed?
- unsigned char c = 0x80; c >>= 1; printf("%d", c); What is printed?
- uint64t big = (uint64t)0xFFFFFFFF 2; What is big?
- enum { A, B = 5, C }; What is the value of C?