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 |
帮我改进一下TLE的程序program pku1001; var r:string[6]; n:integer; t:longint; function HiAdd(a,b:string):string; var c:string; i,jw,j:integer; begin while length(a)<length(b) do a:='0'+a; while length(a)>length(b) do b:='0'+b; jw:=0;c:=''; for i:=length(a) downto 1 do begin j:=ord(a[i])-48+ord(b[i])-48+jw; jw:=j div 10; j:=j mod 10; c:=chr(j+48)+c; end; if jw<>0 then c:=chr(jw+48)+c; HiAdd:=c; end; function HiMul(a,b:string):string; var i,xsws,s,j,jw,r,k:integer; sy,t,zsbf,xsbf,cs1,cs2,zz:string; begin s:=0;xsws:=0; for i:=length(a) downto 1 do begin if a[i]='.' then begin xsws:=xsws+s;cs1:=copy(a,1,i-1)+copy(a,i+1,length(a)- i);break;end; inc(s); end; s:=0; for i:=length(b) downto 1 do begin if b[i]='.' then begin xsws:=xsws+s;cs2:=copy(b,1,i-1)+copy(b,i+1,length(b)- i);break;end; inc(s); end; sy:='';r:=-1; for i:=length(cs2) downto 1 do begin inc(r);t:='';jw:=0; for j:=length(cs1) downto 1 do begin s:=(ord(cs1[j])-48)*(ord(cs2[i])-48)+jw; jw:=s div 10; t:=chr(s mod 10+48)+t; end; if jw<>0 then t:=chr(jw+48)+t; for k:=1 to r do t:=t+'0'; sy:=HiAdd(t,sy); end; while length(sy)<(xsws+1) do sy:='0'+sy; zsbf:=copy(sy,1,length(sy)-xsws); xsbf:=copy(sy,length(sy)-xsws+1,xsws); while zsbf[1]='0' do zsbf:=copy(zsbf,2,length(zsbf)-1); while xsbf[length(xsbf)]='0' do xsbf:=copy(xsbf,1,length(xsbf)-1); zz:=zsbf; if xsbf<>'' then zz:=zz+'.'+xsbf; HiMul:=zz; end; procedure HiPower(r:string;n:integer); var i:integer; a,b:string; begin a:=r;b:=a; for i:=1 to n do a:=HiMul(a,b); writeln(a); end; begin while not eof do begin readln(r,n); HiPower(r,n); end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator