To solve the problem, you can think about it in two directions.
First, we'll have to think about finding a Tn that's smaller than the triangle K.
Let's roughly solve n(n+1)/2 < K with Tn = n(n+1)/2.
If we solve n(n+1) < 2K through the root solution of the quadratic equation, we get n< (sqrt(1+8K) - 1) / 2.
Through the stomach, we now know the trigonometric number n that makes the largest Tn less than K.
Second, when you add each triangle by choosing three numbers from the largest triangle 1 to n, you can think about how K is made.
The simplest solution is
For input value N,
© 2024 OneMinuteCode. All rights reserved.