心血来潮花了一上午做了这道恶心死人的高精度。展示一下打了各种补丁的程序。
type gj=record
len:longint;
data:array[1..1000]of longint;
end;
const num:array[0..3]of integer=(1,10,100,1000);
var x,ans:gj;
c:char;
s:string;
n,i,len,L:longint;
flag:boolean;
procedure change(var x:gj);
var i,j:longint;
begin
j:=0;
fillchar(x.data,sizeof(x.data),0);
for i:=len downto 1 do
begin
if (len-i)mod 4=0 then inc(j);
x.data[j]:=x.data[j]+(ord(s[i])-48)*num[(len-i)mod 4];
end;
x.len:=j;
end;
function mul(a,b:gj):gj;
var i,j:longint;
begin
fillchar(mul.data,sizeof(mul.data),0);
for i:=1 to a.len do
for j:=1 to b.len do
begin
inc(mul.data[i+j-1],a.data[i]*b.data[j]);
inc(mul.data[i+j],mul.data[i+j-1] div 10000);
mul.data[i+j-1]:=mul.data[i+j-1]mod 10000;
end;
if mul.data[i+j]>0 then mul.len:=i+j else mul.len:=i+j-1;
end;
procedure print(m:gj;t:longint);
var i,k,b,e:longint;
w:ansistring;
begin
W:='';
for i:=m.len downto 1 do
BEGIN
w:=w+chr(48+m.data[i]div 1000);
m.data[i]:=m.data[i]mod 1000;
w:=w+chr(48+m.data[i]div 100);
m.data[i]:=m.data[i]mod 100;
w:=w+chr(48+m.data[i]div 10);
m.data[i]:=m.data[i]mod 10;
w:=w+chr(48+m.data[i]);
end;
b:=0;
for i:=1 to length(w) do
if w[i]<>'0' then break else b:=i;
delete(w,1,b);
e:=0;
for i:=length(w) downto 1 do
if w[i]<>'0' then break else inc(e);
delete(w,length(w)-e+1,e);
t:=t-e;
if t<0 then
begin
for i:=1 to abs(t) do w:=w+'0';
t:=0;
end;
if length(w)=0 then begin write(0);exit end;
if t=0 then begin write(w);exit;end;
if length(w)<=t then
begin
write('.');
for i:=1 to t-length(w) do
write('0');
write(w);
end
else
begin
for i:=1 to length(w)-t do
write(w[i]);
write('.');
for i:=length(w)-t+1 to length(w) do
write(w[i]);
end;
end;
begin
while not eof do
begin
len:=0;L:=0;
read(c);flag:=true;
while (c<='9')and(c>='0') do
begin
if flag and(c='0') then begin read(c);continue end else flag:=false;
inc(len);
s[len]:=c;
read(c);
end;
if c<>' ' then read(c);
while c<>' ' do
begin
inc(L);
s[len+L]:=c;
read(c)
end;
inc(len,L);
readln(n);
if n=0 then begin writeln(1);continue end;
change(x);
ans:=x;
for i:=1 to n-1 do
ans:=mul(ans,x);
print(ans,n*L);
writeln
end;
end.