Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
模拟水题……25行无压力~~代码: program poj1068;//By_Thispoet var i,j,p,m,n,te :longint; ans,stack :array[0..50]of longint; st :string; begin readln(te); while te>0 do begin readln(n);p:=0;st:=''; for i:=1 to n do begin read(m); while p<m do begin st:=st+'(';inc(p); end;st:=st+')'; end;m:=0;j:=0;fillchar(stack,sizeof(stack),0); for i:=1 to length(st) do if st[i]=')' then begin inc(j);ans[j]:=stack[m];dec(m);stack[m]:=stack[m+1]+stack[m]; end else begin inc(m);stack[m]:=1; end; for i:=1 to n-1 do write(ans[i],' ');writeln(ans[n]); dec(te); end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator