Triangle Number Sums
A triangle number is a positive integer of the form 1+2+\dots+k. The first triangle numbers are 1, 3, 6, 10 and 15. Every positive integer can be represented as a sum of triangle numbers. For example, 42=21+21 and 1337=1326+10+1. Given a positive integer n, determine the smallest number of triangle numbers that sum to n. Input The first line has an integer t: the number of tests. After that,
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.
Sign in to chat with the tutor and save your progress.
Sign in to start