## 392 - Polynomial Showdown

Moderator: Board moderators

Experienced poster
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Contact:

### Re: 392 WA

First Ans-
There exist a thread for problem no. 392.So why you are creating a new thread.

And then try this-

Code: Select all

``-1 -1 2 3 4 5 0 0 0``

Code: Select all

``-x^8 - x^7 + x^6 + x^5 + x^4 + x^3``
Actual output:-

Code: Select all

``-x^8 - x^7 + 2x^6 + 3x^5 + 4x^4 + 5x^3``
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359

shantanu18
New poster
Posts: 22
Joined: Tue Jul 20, 2010 9:55 pm

### Re: 392 - Polynomial Showdown PE -- plz help

I found the bug of my code. When all input is 0 then output is 0. I missed that. Now AC!

Code: Select all

``````Got AC
``````

al7ssan
New poster
Posts: 1
Joined: Wed Sep 21, 2011 6:03 am

### Re: 392 WA

I'm getting WA with 392 problem.
I had tried every test case and the output is correct . I don't know where is the wrong.
Here is my code, please help Code: Select all

``````# include <iostream>
# include <stdlib.h>
# include <math.h>
using namespace std ;
int main ()
{
//freopen("FILE_NAME_FOR_INPUT.txt","r",stdin);
//freopen("FILE_NAME_FOR OUTPUT.txt","w",stdout);
int j , l , arr;
bool b ;
while(cin >> arr >> arr >> arr >> arr >> arr >> arr >> arr >> arr >> arr)
{
j = 0 ;
b = false ;
for (int i = 8 ; i >= 0 ; i--)
{
if (arr[i] != 0)
{
b = true ;
if (j == 0 && i != 0)
{
if(arr[i] != 1 && arr[i] != -1)
{
cout << arr[i] ;
}
else if(arr[i] == -1)
{
cout << "-" ;
}
}
else if (j == 0 && i == 0)
{
cout << arr[i] ;
}
else
{
if (arr[i] > 1)
{
cout << " + " << arr[i] ;
}
else if (arr[i] < -1)
{
cout << " - " << arr[i] * (-1) ;
}
else if (arr[i] == 1)
{
cout << " + " ;
}
else if (arr[i] == -1)
{
cout << " - " ;
}
}
if (i != 0)
{
if (i == 1)
{
cout << "x" ;
}
else if (i > 1)
{
cout << "x^" << i ;
}
}
j++ ;
}
}
if (b == false)
cout << 0 ;
cout << endl ;
}
return 0 ;
}

``````

please help Gator
New poster
Posts: 3
Joined: Wed May 29, 2013 8:28 am

### Re: 392 - Polynomial Showdown

I think the input for this problem can have leading spaces. As soon as I did a String.trim() on the input line in Java I got AC.