← All problemsSign in

Ayush and children

It's Ayush's birthday today and he wants to give candies to his friends. There are N students, numbered 1,2,…,N in his class. He has total K candies . He has decided not to keep any candy to himself . Here, for each i (1≤i≤N), his i-th friend must receive between 0 and ai candies (inclusive). Also, no candies should be left over. Find the number of ways for him to offer candies, modulo 10^9+7. H

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