Show all threads Hide all threads Show all messages Hide all messages |
wa15 | 👑TIMOFEY👑`~ | 1408. Polynomial Multiplication | 6 Sep 2024 20:44 | 1 |
wa15 👑TIMOFEY👑`~ 6 Sep 2024 20:44 |
Overrated | Keworker `~ | 1408. Polynomial Multiplication | 1 Sep 2024 12:14 | 1 |
Little bit boring, but anyway rating is too big |
help please test #11 | qweqweasd | 1408. Polynomial Multiplication | 19 Dec 2021 00:33 | 5 |
It gives WA please give me test for it (test #11) +1 I have the same problem. Could somebody give a test, please? Tried all the tests of this forum, neither of those helped me. My WA11 x-x x-x Result: 0 My result before AC on WA11: <empty line> |
The shortest program | Alex Tolstov (Vologda STU) | 1408. Polynomial Multiplication | 8 Jul 2021 18:51 | 13 |
My AC program in Java has 396 lines =) And you?))) C++, 144 lines, 3026 characters (including comments, 15 empty lines, and the tracing utilities). pascal 196 o(∩_∩)o... It's not the shortest, but I am really proud of it! Edited by author 22.09.2009 21:13 Java - 330 :) Good architecture is the key for the shortest program and saving nerves.IMHO Edited by author 04.02.2010 21:26 That's funny. This is the first question that comes to mind after the AC. (300 PASCAL lines) Java 186 Edited by author 29.11.2020 17:38 Edited by author 29.11.2020 17:43 Python (74) is really good at these kinds of problems. p1 = Polynomial.parse(input()) p2 = Polynomial.parse(input()) print(p1*p2) |
2 admins (difference in English and Russian statements) | ftc | 1408. Polynomial Multiplication | 4 Feb 2016 19:50 | 2 |
I seems to me that English version of statement has some incorrectness in it. Look at the sentence "Each summand should have no two multipliers of the form X^N with the same X and N.". According to it you may think that summand in form x*x^2 is possible (really, there are no multipliers with same X and N - N's are different). |
Hint for WA #13 | ER | 1408. Polynomial Multiplication | 2 Jul 2014 00:10 | 1 |
A hint for WA #13... make sure that your parser can parse everything that your program can output. |
H!. help me please ihave WA in the test # 8, give me test | Shilov Dmitriy(Vologda SPU#1) | 1408. Polynomial Multiplication | 15 May 2013 16:30 | 5 |
H!. help me please ihave WA in the test # 8, give me test This test helped me: a+a^2+a^3+a^4+a^5+a^6+a^7+a^8+a^9+a^10+a^11+a^12+a^13+a^15+a^14+a^16+a^17+a^18+a^19+a^20+a^21+a^22 b+b^2+b^3+b^4+b^5+b^6+b^7+b^8+b^9+b^10+b^11+b^12+b^13+b^15+b^14+b^16+b^17+b^18+b^19+b^20+b^21+b^22 Answer: a^22*b^22 + a^22*b^21 + a^21*b^22 + a^22*b^20 + a^21*b^21 + a^20*b^22 + a^22*b^19 + a^21*b^20 + a^20*b^21 + a^19*b^22 + a^22*b^18 + a^21*b^19 + a^20*b^20 + a^19*b^21 + a^18*b^22 + a^22*b^17 + a^21*b^18 + a^20*b^19 + a^19*b^20 + a^18*b^21 + a^17*b^22 + a^22*b^16 + a^21*b^17 + a^20*b^18 + a^19*b^19 + a^18*b^20 + a^17*b^21 + a^16*b^22 + a^22*b^15 + a^21*b^16 + a^20*b^17 + a^19*b^18 + a^18*b^19 + a^17*b^20 + a^16*b^21 + a^15*b^22 + a^22*b^14 + a^21*b^15 + a^20*b^16 + a^19*b^17 + a^18*b^18 + a^17*b^19 + a^16*b^20 + a^15*b^21 + a^14*b^22 + a^22*b^13 + a^21*b^14 + a^20*b^15 + a^19*b^16 + a^18*b^17 + a^17*b^18 + a^16*b^19 + a^15*b^20 + a^14*b^21 + a^13*b^22 + a^22*b^12 + a^21*b^13 + a^20*b^14 + a^19*b^15 + a^18*b^16 + a^17*b^17 + a^16*b^18 + a^15*b^19 + a^14*b^20 + a^13*b^21 + a^12*b^22 + a^22*b^11 + a^21*b^12 + a^20*b^13 + a^19*b^14 + a^18*b^15 + a^17*b^16 + a^16*b^17 + a^15*b^18 + a^14*b^19 + a^13*b^20 + a^12*b^21 + a^11*b^22 + a^22*b^10 + a^21*b^11 + a^20*b^12 + a^19*b^13 + a^18*b^14 + a^17*b^15 + a^16*b^16 + a^15*b^17 + a^14*b^18 + a^13*b^19 + a^12*b^20 + a^11*b^21 + a^10*b^22 + a^22*b^9 + a^21*b^10 + a^20*b^11 + a^19*b^12 + a^18*b^13 + a^17*b^14 + a^16*b^15 + a^15*b^16 + a^14*b^17 + a^13*b^18 + a^12*b^19 + a^11*b^20 + a^10*b^21 + a^9*b^22 + a^22*b^8 + a^21*b^9 + a^20*b^10 + a^19*b^11 + a^18*b^12 + a^17*b^13 + a^16*b^14 + a^15*b^15 + a^14*b^16 + a^13*b^17 + a^12*b^18 + a^11*b^19 + a^10*b^20 + a^9*b^21 + a^8*b^22 + a^22*b^7 + a^21*b^8 + a^20*b^9 + a^19*b^10 + a^18*b^11 + a^17*b^12 + a^16*b^13 + a^15*b^14 + a^14*b^15 + a^13*b^16 + a^12*b^17 + a^11*b^18 + a^10*b^19 + a^9*b^20 + a^8*b^21 + a^7*b^22 + a^22*b^6 + a^21*b^7 + a^20*b^8 + a^19*b^9 + a^18*b^10 + a^17*b^11 + a^16*b^12 + a^15*b^13 + a^14*b^14 + a^13*b^15 + a^12*b^16 + a^11*b^17 + a^10*b^18 + a^9*b^19 + a^8*b^20 + a^7*b^21 + a^6*b^22 + a^22*b^5 + a^21*b^6 + a^20*b^7 + a^19*b^8 + a^18*b^9 + a^17*b^10 + a^16*b^11 + a^15*b^12 + a^14*b^13 + a^13*b^14 + a^12*b^15 + a^11*b^16 + a^10*b^17 + a^9*b^18 + a^8*b^19 + a^7*b^20 + a^6*b^21 + a^5*b^22 + a^22*b^4 + a^21*b^5 + a^20*b^6 + a^19*b^7 + a^18*b^8 + a^17*b^9 + a^16*b^10 + a^15*b^11 + a^14*b^12 + a^13*b^13 + a^12*b^14 + a^11*b^15 + a^10*b^16 + a^9*b^17 + a^8*b^18 + a^7*b^19 + a^6*b^20 + a^5*b^21 + a^4*b^22 + a^22*b^3 + a^21*b^4 + a^20*b^5 + a^19*b^6 + a^18*b^7 + a^17*b^8 + a^16*b^9 + a^15*b^10 + a^14*b^11 + a^13*b^12 + a^12*b^13 + a^11*b^14 + a^10*b^15 + a^9*b^16 + a^8*b^17 + a^7*b^18 + a^6*b^19 + a^5*b^20 + a^4*b^21 + a^3*b^22 + a^22*b^2 + a^21*b^3 + a^20*b^4 + a^19*b^5 + a^18*b^6 + a^17*b^7 + a^16*b^8 + a^15*b^9 + a^14*b^10 + a^13*b^11 + a^12*b^12 + a^11*b^13 + a^10*b^14 + a^9*b^15 + a^8*b^16 + a^7*b^17 + a^6*b^18 + a^5*b^19 + a^4*b^20 + a^3*b^21 + a^2*b^22 + a^22*b + a^21*b^2 + a^20*b^3 + a^19*b^4 + a^18*b^5 + a^17*b^6 + a^16*b^7 + a^15*b^8 + a^14*b^9 + a^13*b^10 + a^12*b^11 + a^11*b^12 + a^10*b^13 + a^9*b^14 + a^8*b^15 + a^7*b^16 + a^6*b^17 + a^5*b^18 + a^4*b^19 + a^3*b^20 + a^2*b^21 + a*b^22 + a^21*b + a^20*b^2 + a^19*b^3 + a^18*b^4 + a^17*b^5 + a^16*b^6 + a^15*b^7 + a^14*b^8 + a^13*b^9 + a^12*b^10 + a^11*b^11 + a^10*b^12 + a^9*b^13 + a^8*b^14 + a^7*b^15 + a^6*b^16 + a^5*b^17 + a^4*b^18 + a^3*b^19 + a^2*b^20 + a*b^21 + a^20*b + a^19*b^2 + a^18*b^3 + a^17*b^4 + a^16*b^5 + a^15*b^6 + a^14*b^7 + a^13*b^8 + a^12*b^9 + a^11*b^10 + a^10*b^11 + a^9*b^12 + a^8*b^13 + a^7*b^14 + a^6*b^15 + a^5*b^16 + a^4*b^17 + a^3*b^18 + a^2*b^19 + a*b^20 + a^19*b + a^18*b^2 + a^17*b^3 + a^16*b^4 + a^15*b^5 + a^14*b^6 + a^13*b^7 + a^12*b^8 + a^11*b^9 + a^10*b^10 + a^9*b^11 + a^8*b^12 + a^7*b^13 + a^6*b^14 + a^5*b^15 + a^4*b^16 + a^3*b^17 + a^2*b^18 + a*b^19 + a^18*b + a^17*b^2 + a^16*b^3 + a^15*b^4 + a^14*b^5 + a^13*b^6 + a^12*b^7 + a^11*b^8 + a^10*b^9 + a^9*b^10 + a^8*b^11 + a^7*b^12 + a^6*b^13 + a^5*b^14 + a^4*b^15 + a^3*b^16 + a^2*b^17 + a*b^18 + a^17*b + a^16*b^2 + a^15*b^3 + a^14*b^4 + a^13*b^5 + a^12*b^6 + a^11*b^7 + a^10*b^8 + a^9*b^9 + a^8*b^10 + a^7*b^11 + a^6*b^12 + a^5*b^13 + a^4*b^14 + a^3*b^15 + a^2*b^16 + a*b^17 + a^16*b + a^15*b^2 + a^14*b^3 + a^13*b^4 + a^12*b^5 + a^11*b^6 + a^10*b^7 + a^9*b^8 + a^8*b^9 + a^7*b^10 + a^6*b^11 + a^5*b^12 + a^4*b^13 + a^3*b^14 + a^2*b^15 + a*b^16 + a^15*b + a^14*b^2 + a^13*b^3 + a^12*b^4 + a^11*b^5 + a^10*b^6 + a^9*b^7 + a^8*b^8 + a^7*b^9 + a^6*b^10 + a^5*b^11 + a^4*b^12 + a^3*b^13 + a^2*b^14 + a*b^15 + a^14*b + a^13*b^2 + a^12*b^3 + a^11*b^4 + a^10*b^5 + a^9*b^6 + a^8*b^7 + a^7*b^8 + a^6*b^9 + a^5*b^10 + a^4*b^11 + a^3*b^12 + a^2*b^13 + a*b^14 + a^13*b + a^12*b^2 + a^11*b^3 + a^10*b^4 + a^9*b^5 + a^8*b^6 + a^7*b^7 + a^6*b^8 + a^5*b^9 + a^4*b^10 + a^3*b^11 + a^2*b^12 + a*b^13 + a^12*b + a^11*b^2 + a^10*b^3 + a^9*b^4 + a^8*b^5 + a^7*b^6 + a^6*b^7 + a^5*b^8 + a^4*b^9 + a^3*b^10 + a^2*b^11 + a*b^12 + a^11*b + a^10*b^2 + a^9*b^3 + a^8*b^4 + a^7*b^5 + a^6*b^6 + a^5*b^7 + a^4*b^8 + a^3*b^9 + a^2*b^10 + a*b^11 + a^10*b + a^9*b^2 + a^8*b^3 + a^7*b^4 + a^6*b^5 + a^5*b^6 + a^4*b^7 + a^3*b^8 + a^2*b^9 + a*b^10 + a^9*b + a^8*b^2 + a^7*b^3 + a^6*b^4 + a^5*b^5 + a^4*b^6 + a^3*b^7 + a^2*b^8 + a*b^9 + a^8*b + a^7*b^2 + a^6*b^3 + a^5*b^4 + a^4*b^5 + a^3*b^6 + a^2*b^7 + a*b^8 + a^7*b + a^6*b^2 + a^5*b^3 + a^4*b^4 + a^3*b^5 + a^2*b^6 + a*b^7 + a^6*b + a^5*b^2 + a^4*b^3 + a^3*b^4 + a^2*b^5 + a*b^6 + a^5*b + a^4*b^2 + a^3*b^3 + a^2*b^4 + a*b^5 + a^4*b + a^3*b^2 + a^2*b^3 + a*b^4 + a^3*b + a^2*b^2 + a*b^3 + a^2*b + a*b^2 + a*b Yes, I had wa8, this test has helped me, the mistake was sorted degrees |
For the ones who has WA36 | Borozdin Kirill | 1408. Polynomial Multiplication | 18 Jun 2011 21:08 | 1 |
This test looks something like 1 -1 ______ -1 Good luck! |
note for WA#12 | hoan | 1408. Polynomial Multiplication | 28 Dec 2010 23:41 | 5 |
dont read space in the input. What do you mean? Firstly I read two lines of text, then I parse it using '+' and '-' as parsing symbols, and, after that I delete spaces from every substring I got. And I have WA#12. Do you want to say it is wrong algo? If so, could you give a test to clarify what you mean, please? Edited by author 27.12.2010 18:52 try this test: .......x^..2*...y^...0-1 ...y +.....000 output: x^2*y - y (dote meane space) hope can help you!!! Edited by author 28.12.2010 14:35 Edited by author 28.12.2010 14:36 My program passed this test. Moreover, it passed all tests from this forum! Do you have another one? :) Edited by author 28.12.2010 18:32 sorry, this test very useful for me. hope you can get AC. GOOD LUCK!!! Edited by author 28.12.2010 23:41 |
Not trust! | svr | 1408. Polynomial Multiplication | 24 Oct 2010 14:44 | 4 |
I do not trust that this problem can be solved during contest! Because it demand big amount of tehnical work such as grammar analysis, string manipulations and sorting. you're kidding right? I think it can be done in less than an hour, it's no big deal the parsing and string manipulation. Did you have some tests that failed you program? I think mine is ok, but WA9! A lot of time wasted to find a mistake... With no result. Maybe some tricky tests?... Edited by author 24.04.2007 23:29 Sure, for a competent programmer it is possible to hack it in an hour, but since it is for a school contest, I do not expect many teams to be able to solve it. Moderators, do we have the statistics the real contest it was taken from? |
If you have WA @ 2 or 4. | 198808xc | 1408. Polynomial Multiplication | 29 Sep 2010 19:34 | 1 |
Test 2 is the case that output is 0. For example: Input a - a b Output 0 (My output was nothing) Test 4 is the case that some power would be 0. For example: Input a^00 - b 1 - b*b^0 Output b^2 - 2*b + 1 Good luck. |
Strange test #13 | SevenEleven [Tartu U] | 1408. Polynomial Multiplication | 29 Sep 2010 19:19 | 3 |
when I changed char buf[100]; cin.getline(buf, 100); to char buf[1000]; cin.getline(buf, 1000); I got AC, but problem statement says that polynom's length is no longer than 100 characters. Because there is a '\0' character in the end of string, so for string with length 100 you should use "char buf[101]". And, when you use cin.getline() to read a line of max-length 100, you should write: cin.getline(*, 101, '\n'); instead of cin.getline(*, 100, '\n'); |
wa 12 | unlucky [Vologda SPU] | 1408. Polynomial Multiplication | 4 Feb 2010 21:21 | 1 |
wa 12 unlucky [Vologda SPU] 4 Feb 2010 21:21 Try to check your output in case, were coefficient's are negative. For example: 0*z^2-z^1 ans -z It's very important to check output of singums! |
for 6 test | unlucky [Vologda SPU] | 1408. Polynomial Multiplication | 4 Feb 2010 19:56 | 1 |
|
test#5 | qweqweasd | 1408. Polynomial Multiplication | 3 Oct 2009 15:30 | 1 |
test#5 qweqweasd 3 Oct 2009 15:30 it gives error (Crash) . how can i solve it? can you give me hint? thanks |
There are multiply spaces in the 2nd test (-) | Dart MirzMan C++ Edition (Mirzoyan Alexey, Rybinsk SAAT) | 1408. Polynomial Multiplication | 21 Jun 2009 13:22 | 2 |
This test helped me passing Test #2 1 0 --- 0 Edited by author 21.06.2009 13:22 |
Strange! why crash 1 ?????!!!!!!!! | lhmhl | 1408. Polynomial Multiplication | 17 May 2009 14:37 | 1 |
type fu1=array['a'..'z'] of longint; su=record a:fu1; zf:integer; x:longint; end; kk1=array[1..1000] of su; var a,b,c:kk1; d:su; i,j,k,l,x,y,n,m:longint; s:string; g:boolean; ch:char; function jun(g:boolean):integer; begin if g then exit(1) else exit(-1); end; procedure doit(var a:kk1; var n:longint); var g:boolean; c:char; num:string; nu:longint; begin readln(s); num:=''; for i:=1 to length(s) do if s[i]<>' ' then num:=num+s[i]; s:=''; for i:=1 to length(num) do begin if num[i] in[ '+','-'] then begin if i<>1 then s:=s+' '+num[i]+' ' else s:=s+num[i]; end else begin s:=s+num[i]; end; end; g:=true; if s[1] in ['+','-'] then begin if s='-' then g:=false; delete(s,1,1); end; repeat i:=pos(' ',s); l:=length(s); if i=0 then i:=l+1; d.zf:=jun(g); d.x:=d.zf; fillchar(d.a,sizeof(d.a),0); if s[1] in ['0'..'9'] then begin num:=''; while (s[1] in ['0'..'9']) and (length(s)<>0) do begin num:=num+s[1]; delete(s,1,1); end; if s[1]<>' ' then delete(s,1,1); val(num,j,nu); d.x:=j*d.zf; i:=pos(' ',s); l:=length(s); if i=0 then i:=l+1; end; if d.x=0 then begin delete(s,1,i-1); g:=s[2]='+'; delete(s,1,3); continue; end; if s[1]=' ' then begin inc(n); a[n]:=d; g:=s[2]='+'; delete(s,1,3); continue; end; if length(s)=0 then begin inc(n); a[n]:=d; break; end; k:=1; j:=1; while j<=i do begin c:=s[j]; k:=1; if (j>=i) then inc(j,2) else begin if s[j+1]='^' then begin inc(j,2); num:=''; while s[j] in ['0'..'9'] do begin num:=num+s[j]; inc(j); if (j>i) or (j=l+1) then break; end; inc(j); val(num,k,nu); end else inc(j,2); end; d.a[c]:=d.a[c]+k; end; delete(s,1,i-1); if i<>l+1 then begin g:=s[2]='+'; delete(s,1,3); end; inc(n); a[n]:=d; until i=l+1; end; function jia(a,b:su):su; var i:longint; c:char; begin a.x:=a.x*b.x; for c:='a' to 'z' do a.a[c]:=a.a[c]+b.a[c]; exit(a); end; function ok(a,b:su):boolean; var c:char; begin for c:='a' to 'z' do begin if a.a[c]<>b.a[c] then exit(false); end; exit(true); end; function bijiao1(a,b:su):boolean; var c:char; i,x,y:longint; begin i:=2; x:=0; y:=0; for c:='a' to 'z' do begin x:=x+a.a[c]; y:=y+b.a[c]; if (i=2) then begin if a.a[c]>=b.a[c] then begin if a.a[c]>b.a[c] then i:=1 end else i:=0; end; end; if (x<y) or ((i=0) and(x=y) ) then exit(true) else exit(false); end; begin { fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); fillchar(c,sizeof(c),0); } n:=0; m:=0; doit(a,n); doit(b,m); k:=0; for i:=1 to n do begin for j:=1 to m do begin d:=jia(a[i],b[j]); g:=true; for x:=1 to k do begin if ok(c[x],d) then begin c[x].x:=c[x].x+d.x; g:=false; break; end; end; if g then begin inc(k); c[k]:=d; end; end; end; for i:=1 to k-1 do for j:=i+1 to k do begin if bijiao1(c[i],c[j]) then begin d:=c[i]; c[i]:=c[j]; c[j]:=d; end; end; for i:=1 to k do begin if (c[i].x=0) then continue; if (c[i].x>0) then begin if i<>1 then write('+'); if i<>1 then write(' '); end else begin write('-'); if i<>1 then write(' '); end; c[i].x:=abs(c[i].x); g:=true; if c[i].x<>1 then write(c[i].x); for ch:='a' to 'z' do begin if c[i].a[ch]=0 then continue; if (c[i].x<>1) or (g=false) then write('*'); g:=false; write(ch); if c[i].a[ch]<>1 then write('^',c[i].a[ch]); end; if g and (c[i].x=1) then write(1); if i<>k then write(' '); end; end. i think there's no problem with mine Edited by author 17.05.2009 14:38 |
What's wrong with the test#9? My Program passes all my own tests and tests from forum! Help me, please! (-) | Alexey | 1408. Polynomial Multiplication | 13 Apr 2009 10:56 | 5 |
1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 i've passed it and all tests from forum, anw wa12. please, i need a test or a hint/ AC now. Edited by author 13.04.2009 10:56 Edited by author 13.04.2009 19:12 |
WA#12 | Loky_Yuri [USTU Frogs] | 1408. Polynomial Multiplication | 11 Apr 2009 15:27 | 4 |
WA#12 Loky_Yuri [USTU Frogs] 3 Mar 2008 10:12 This tests helped me find many bugs in my programm. a + b a + b --- a^2 + 2*a*b + b^2 a + b a - b --- a^2 - b^2 a - b a - b --- a^2 - 2*a*b + b^2 And this: 12*x + 15*x^2 - 21y^1*y 5*a^1 - 1 + 0 + 1*b*b*b --- 15*b^3*x^2 - 21*b^3*y^2 + 12*b^3*x + 75*a*x^2 - 105*a*y^2 + 60*a*x - 15*x^2 + 21*y^2 - 12*x Re: WA#12 Dmitry "Logam" Kobelev [TSOGU] 7 Mar 2008 22:58 Last test is very useful. Thx. But there is a bug in the first line : 21y^1*y - multipliers must be separated with '*' symbols Re: WA#12 Loky_Yuri [USTU Frogs] 8 Mar 2008 22:43 Oh, yes! Of course you are right. Sorry for my mistake. Re: WA#12 Alexander Mangilyov (TNU) 11 Apr 2009 15:27 There can be whitespaces in the beginning of the expression |
I Crash (access violation) on #5. Need for your help. | ZvezdaM | 1408. Polynomial Multiplication | 9 Oct 2008 12:45 | 1 |
|