link to ques. http://www.codechef.com/problems/TRISQ
link to sol. http://www.codechef.com/viewsolution/6882812
One needs to find No. of squares in a triangle
What you are doing is that for all the t i.e test cases you take the input and then give output for all simultaneously which is wrong.
You need to take input and just after that give output and then again take input and so on.
here is my solution
#include<iostream>
using namespace std;
int main()
{
int t;cin>>t;
while(t--)
{
int n;
cin>>n;
n=n/2;
n= n-1;
n = (n*(n+1))/2;
cout<<n<<endl;
}
}
What you are doing is that for all the t i.e test cases you take the input and then give output for all simultaneously which is wrong.
You need to take input and just after that give output and then again take input and so on.
here is my solution
#include<iostream>
using namespace std;
int main()
{
int t;cin>>t;
while(t--)
{
int n;
cin>>n;
n=n/2;
n= n-1;
n = (n*(n+1))/2;
cout<<n<<endl;
}
}