392 - Polynomial Showdown

All about problems in Volume 3. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
User avatar
yahoo
Learning poster
Posts: 93
Joined: Tue Apr 23, 2002 9:55 am

problem with 392

Post by yahoo » Thu May 30, 2002 6:30 pm

Can anyone tell me the reason why i got wrong answer in this problem.Can anyone give some input?
Here is my prograrm:

#include <stdio.h>
#include <math.h>

main()
{
int r,a[10],i,cnt;
while(1)
{
cnt =0;
r=scanf("%d%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8]);
if(r==EOF) break;
for (i=0;i<9;i++)
if (a!=0)
{
if (cnt>=1)
{
if (a<0) printf(" - ");
else printf(" + ");
}
else if (cnt<1 && a<0) printf("-");

if (a<0) a=a*(-1);
if (i<7)
{
if (a==1)
printf("x^%d",9-i-1);
else
printf("%dx^%d",a,9-i-1);
}
if (i==7)
{
if (a==1)
printf("x");
else printf("%d^x",a);
}
if (i==8)
printf("%d",a[i]);
cnt++;
}
if (cnt==0) printf("0");
printf("\n");
}

return 0;
}

Ivor
Experienced poster
Posts: 150
Joined: Wed Dec 26, 2001 2:00 am
Location: Tallinn, Estonia

Post by Ivor » Thu May 30, 2002 7:09 pm

do a favor and use a code tag.
about line 12(?) from bottom:

Code: Select all

else printf("%d^x",a[i]); 
why do you have '%d^x'? maybe you meant 'x^%d'?

Ivor

User avatar
yahoo
Learning poster
Posts: 93
Joined: Tue Apr 23, 2002 9:55 am

Post by yahoo » Tue Jun 04, 2002 7:42 pm

I have soved this.But still it give wrong answer.Is there any problem more. i can't find any typical data.Please help me.

User avatar
rakeb
New poster
Posts: 42
Joined: Fri Aug 30, 2002 2:51 pm
Location: France

392 PLZ Help

Post by rakeb » Fri Nov 22, 2002 5:54 pm

What will be the out put if all inputs are zero
i.e.
0 0 0 0 0 0 0 0 0
unless all terms have zero coefficients in which case the constant term should appear
what is this line meaning i can't understand.....

Thanks

Ivan Golubev
Experienced poster
Posts: 167
Joined: Fri Oct 19, 2001 2:00 am
Location: Saint Petersburg, Russia

Re: 392 PLZ Help

Post by Ivan Golubev » Fri Nov 22, 2002 9:11 pm

rakeb wrote:What will be the out put if all inputs are zero
i.e.
0 0 0 0 0 0 0 0 0
Output is just 0.

User avatar
angga888
Experienced poster
Posts: 143
Joined: Sat Dec 21, 2002 11:41 am
Location: Indonesia

392 - Polynomial Showdown

Post by angga888 » Thu Dec 26, 2002 1:36 pm

I got WA and WA again in 392. :(
Please check my output according to these input

/****INPUT*******/
0 0 0 1 22 -333 0 1 -1
-1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 -7 30 66
0 0 0 0 0 0 1 -3 0
0 0 0 0 0 -1 1 3 -1
-5 0 0 0 -243 0 0 0 -9
-0 -1 -1 -1 -1 -1 -1 -1 -1
-1999999999 -978456 0 0 0 0 56 -89 8


/****OUTPUT*****/
x^5 + 22x^4 - 333x^3 + x - 1
-x^8
0
-7x^2 + 30x + 66
x^2 - 3x
-x^3 + x^2 + 3x - 1
-5x^8 - 243x^4 - 9
-x^7 - x^6 - x^5 - x^4 - x^3 - x^2 - x - 1
-1999999999x^8 - 978456x^7 + 56x^2 - 89x + 8

Isn't that all right? Please tell me if any of them are wrong.
And please give me another creative and strange input.

Regards,
Angga888

Andrey Mokhov
Experienced poster
Posts: 128
Joined: Fri Nov 15, 2002 7:45 am
Location: Kyrgyzstan

Post by Andrey Mokhov » Fri Dec 27, 2002 9:02 am

Your output is right.
Try this also.
Input:

Code: Select all

0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0  1
0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 -1 0
Output:

Code: Select all

-1
1
x
-x
Good luck!

User avatar
angga888
Experienced poster
Posts: 143
Joined: Sat Dec 21, 2002 11:41 am
Location: Indonesia

Post by angga888 » Sat Dec 28, 2002 7:47 am

According to your test input, my program also gives the correct output.
But still WA? :( Any other suggestion?
Is there any possibilities that the input doesn't contain 9 integer (maybe less than 9) ?

Regards,
Angga888

junjieliang
Experienced poster
Posts: 169
Joined: Wed Oct 31, 2001 2:00 am
Location: Singapore

Post by junjieliang » Sun Dec 29, 2002 7:44 am

No I don't remember any problems with input. What I do remember is that this problem has a LOT of tricky cases and you have to track them down one by one. I recalled getting quite frustrated before AC...

Problem is, I don't remember the tricky cases already.

Good luck!

User avatar
angga888
Experienced poster
Posts: 143
Joined: Sat Dec 21, 2002 11:41 am
Location: Indonesia

Post by angga888 » Sun Dec 29, 2002 8:02 am

It's Ok if you don't remember the tricky cases.
Since I still got WA in this problem, would you mind sending your 392.exe file to my e-mail (angga888@indosat.net.id) to check my program again ? :wink:
Thanx.

Regards,
Angga888

Andrey Mokhov
Experienced poster
Posts: 128
Joined: Fri Nov 15, 2002 7:45 am
Location: Kyrgyzstan

Post by Andrey Mokhov » Mon Dec 30, 2002 10:10 am

I will send you my code. But I can't do it now. I'll send it a few days later. Ok? It's so rush time now - holydays, snow, mountains...
Well that's fine. :lol: I just can't get the computer where I keep the codes... :wink:

Happy new year to everybody!

User avatar
angga888
Experienced poster
Posts: 143
Joined: Sat Dec 21, 2002 11:41 am
Location: Indonesia

Post by angga888 » Mon Jan 06, 2003 6:43 am

Thx Andrey Mokhov for your 392.exe file.
After I got your exe file, I gived so many inputs to your exe file and compared the output with mine. But my output was correct for all those inputs.
Finally, I tried to submit the problem once more and I added one more line in my program (readln(input)) and I got Accepted. :D
Maybe, the judge test cases, can be more than 9 integers and we must calculate for the first 9 integers and ignore the rests. :wink:
I think that's why I always got WA and WA.

Regards
Angga888

deddy one
Experienced poster
Posts: 120
Joined: Tue Nov 12, 2002 7:36 pm

Post by deddy one » Mon Jan 06, 2003 8:24 am

I used

while (scanf ("%d%d%d%d%d%d%d%d%d",
&poly[0],& bla bla bla bla bla ) == 9)

and I got accepted

I use C to solve it, I don't know anything about
pascal input reading :wink:


best regards.

jeanmart
New poster
Posts: 1
Joined: Wed Jan 29, 2003 9:38 am

P392 Polynomial Showdown

Post by jeanmart » Wed Jan 29, 2003 9:43 am

Do not forget to add at least one blank space at the end of each
answer line (as not specified in the rules). Otherwise, you get a WA.

Eric
Learning poster
Posts: 83
Joined: Wed Sep 11, 2002 6:28 pm
Location: Hong Kong

Re: P392 Polynomial Showdown

Post by Eric » Sun Mar 30, 2003 10:57 am

jeanmart wrote:Do not forget to add at least one blank space at the end of each
answer line (as not specified in the rules). Otherwise, you get a WA.
Really?
I didn't add any spaces but I still got Accepted.
I think the space doesn't matter.

Post Reply

Return to “Volume 3 (300-399)”