← All problemsSign in

Program11

Code given below is intended to find no. of solutions to the equation : a + b + c ≤ N, such that 0 ≤ a ≤ A, 0 ≤ b ≤ B, 0 ≤ c ≤ C. 0 ≤ N,A,B,C ≤ 2500 long long int f(long long int n) { long long int r; r = (n+1)(n+2)(n+3); return (r/6) ; } main() { long long int N,A,B,C; scanf("%lld%lld%lld%lld",N,A,B,C); printf("%lld\n",f(N)-f(N-A-1)-f(N-B-1)-f(N-C-1)+f(N-A-B-2)+f(N-A-C-2)+f(N-C-B-2

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start