← All problemsSign in

Chef and Triplets

Chef's maths teacher gave him a simple homework. He gave chef two positive integers k and s. Chef has to choose 3 integers x,y and z such that x+y+z=s and 0 Input Two integers k and s. Output Single integer denoting the number of triplets (x,y,z) that can be formed. Constraints - 2 ≤ K ≤ 2500 - 0 ≤ s ≤ 3*K Example Input: 5 15 Output: 1

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