UVa OJ 748-Exponentiation
2011-02-09 20:57
197 查看
高精:
{ Author:wzx961008 Problem:UVa 748-Exponentiation Verdict:Accepted Language:PASCAL Run Time:0.016s Submission Date:2011-02-09 12:55:02 } var s:string[9]; base,ans:ansistring; pt,ps,pp,i,m:longint; function HighMultiply(s1,s2:ansistring):ansistring; var a,b,c:array[1..10000]of integer; lena,lenb,lenc,i,j,x:integer; begin fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); fillchar(c,sizeof(c),0); HighMultiply:=''; lena:=length(s1); lenb:=length(s2); for i:=1 to lena do a[lena-i+1]:=ord(s1[i])-ord('0'); for i:=1 to lenb do b[lenb-i+1]:=ord(s2[i])-ord('0'); for i:=1 to lena do begin x:=0; for j:=1 to lenb do begin x:=a[i]*b[j]+x div 10+c[i+j-1]; c[i+j-1]:=x mod 10; end; c[i+j]:=x div 10; end; lenc:=i+j; while (c[lenc]=0)and(lenc>1) do dec(lenc); for i:=lenc downto 1 do HighMultiply:=HighMultiply+chr(c[i]+48); end; begin while not eof do begin readln(s); ps:=pos(' ',s); if s[ps+1]<>' ' then m:=(ord(s[ps+1])-48)*10+(ord(s[ps+2])-48) else m:=ord(s[ps+2])-48; pp:=pos('.',s); for i:=ps downto pp do begin if (s[i]>='1')and(s[i]<='9') then break; if s[i]='0' then delete(s,i,1); end; pt:=(i-pp)*m; base:=''; for i:=1 to i do if s[i]<>'.' then base:=base+s[i]; ans:=base; for i:=1 to m-1 do ans:=HighMultiply(ans,base); while pt>length(ans) do ans:='0'+ans; insert('.',ans,length(ans)-pt+1); writeln(ans); end; end.
相关文章推荐
- UVa:748 - Exponentiation
- UVA - 748 Exponentiation 高精度
- UVA 748 Exponentiation
- Uva 748 - Exponentiation(大数相乘)
- uva 748 Exponentiation(高精度实数乘法)
- UVa 748 Exponentiation
- 748 - Exponentiation
- UVA 748 Exponentiation
- UVa 748 - Exponentiation
- UVa 748 / POJ 1001 Exponentiation (浮点高精度求幂&正则表达式的应用)
- UVA748 Exponentiation
- UVa 748 Exponentiation解题报告
- UVa 748 Exponentiation
- 748 - Exponentiation
- UVa748 Exponentiation
- uva748 - Exponentiation
- UVA748 Exponentiation
- UVA 748 - Exponentiation
- POJ 1001 & UVa 748 - Exponentiation in JAVA
- UVA 748 Exponentiation