Help me in solving TRICOIN problem

My code

``````# cook your dish here
n=int(input())
for i in range(n):

``````

Learning course: Binary Search
Problem Link: Coins And Triangle Practice Problem in Binary Search - CodeChef

@divya78094
refer the following code

``````#include <iostream>
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int count = 0;
for(int i=1;i<=n;i++){
n-=i;
if(n>=0){
count++;
}
}
cout<<count<<endl;
}
return 0;
}``````

here your partial code is taking input for number of test cases and run the group of code for each test case
for you we can start code with

``````n=int(input())
for i in range(n):
num=int(input())
i=1
while(i*(i+1)<n):
i=i+1
if i*(i+1)/2==n:
print(i)
else:
print(i-1)
``````

Here is the solution :-

include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin >> t;

``````while(t--){
int n, result = 0;
cin >> n;
int check = n;
int i=1;

while(check >= i){                // check coins are able to fill next row or not
result++;                         // counting rows
check = check - i;         // reduce used coins
i++;                               // increasing coins count
}

cout << result << endl;        // printing Output

}
``````

}