title: Triangles and Cubic Polynomials?
body: <p>Given 2 cubic equations of the form (A∗X^3+B∗X^2+C∗X)
  find out how many obtuse triangles could be formed from the roots of the 2 equations.</p>
  
  <p>Note that only positive roots could be a triangle side, so any triangle should be formed of 333 positive roots (sides).</p>
  
  <p>Input Constraints:</p>
  
  <p>1≤T≤10^6</p>
  
  <p>(−4∗10^8)≤A1,B1,C1,A2,B2,C2≤(4∗10^8)</p>
  
  <p>Format of the input file:
  First line : T i.e number of testcases
  For each testcase :
  First line : Three space separated integers A1, B1 and C1 
  Second line : Three space separated integers A2, B2 and C2.
  <a href="https://i.stack.imgur.com/0HoRP.png" rel="nofollow noreferrer">images for test case</a><a href="https://i.stack.imgur.com/w3zPv.png" rel="nofollow noreferrer">2</a></p>
  
  <p><strong>My code is:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;math.h&gt;
  using namespace std;
  
  int* roots()
  {   
  long int a,b,c;
  int *x=new int[2];
  int determinant;
  cin &gt;&gt; a &gt;&gt; b &gt;&gt; c;
   determinant = b*b - 4*a*c;
  
  if (determinant &gt; 0) {
      x[1] = (-b + sqrt(determinant)) / (2*a);
      x[0] = (-b - sqrt(determinant)) / (2*a);
  
  }
  
  else {
      x[1] = -b/(2*a);
      x[0]=x[1];
  }
  
  return x;
  }
  
  
  int main()
  {int t;
  int *a,*b,x,y,z,c,i;
    cin&gt;&gt;t;
   do{c=0;
      a=roots();
     b=roots(); 
     for(i=0;i&lt;2;i++)
     {x=a[i]*a[i];
     y=b[i]*b[i];
     if(x!=0&amp;&amp;y!=0)
     {switch(i)
     {
         case 0:z=a[1]*a[1];
  
              if(((x+y)&lt;z||y+z&lt;x||x+z&lt;y)&amp;&amp;z!=0)
                  c++;
                  z=b[1]*b[1];
                  if(((x+y)&lt;z||y+z&lt;x||x+z&lt;y)&amp;&amp;z!=0)
                  c++;
                  break;
          case 1:z=a[0]*a[0];
  
              if(((x+y)&lt;z||y+z&lt;x||x+z&lt;y)&amp;&amp;z!=0)
                  c++;
                  z=b[0]*b[0];
                  if(((x+y)&lt;z||y+z&lt;x||x+z&lt;y)&amp;&amp;z!=0)
                  c++;
                  break;
  
     }
     }
     }
  
      cout&lt;&lt;c&lt;&lt;"\n";
      t--;
  }while(t);
  return 0;
  </code></pre>
  
  <p>}</p>