1 / 2
Apr 2017

_

problem link=http://www.spoj.com/problems/MATHLOVE/

_

include

include

using namespace std;
int main()
{
int n,i,e,r,p;
cin>>n;
int a[n],d[n];
for(i=0;i<n;i++)
{
cin>>a[i];
e=2*a[i];
p=sqrt(4*e+1);
if(p*p==4*e+1)
{
r=(p-1)/2;
d[i]=r;
}
else
d[i]=0;
}
for(i=0;i<n;i++)
{
if(d[i]==0)
cout<<"NAN"<<"\n";
else
cout<<d[i]<<"\n";
}
return 0;
}

  • created

    Apr '17
  • last reply

    Aug '17
  • 1

    reply

  • 773

    views

  • 2

    users

4 months later

Well, the first thing to do is to define n, i, e, r, p.
the first lines, which I corrected, should look like it

void setup() {

using namespace std;
{
int main() ;
int (n,i,e,r,p);
cin>>n;

More than that I cannot say, as I need to know what n, i, e, r, p are.
If you can tell me, I can help you further.
Other than that, it is a good program

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 41 Jun 29

Want to read more? Browse other topics in C and C++ or view latest topics.