Title Link: HTTP://HHHOJ.NGROK.CC/CONTEST/3/PROBLEM/4
High-precision multiplication
Just add a little bit of the decimal point, please.
Note the 0 and output specifications before and after
Paste Code
Type arr=array[0..300]of longint;
var s:string;
N,x,bo,i,j,t,len,bo1:longint;
Ans,a:arr;
function Mul (A,b:arr): arr;
var i,j:longint;
var C:arr;
Begin Fillchar (C,sizeof (c), 0);
C[0]:=a[0]+b[0]-1;
For I:=1 to A[0] does for j:=1 to B[0] DO BEGIN Inc (C[I+J-1],A[I]*B[J]);
Inc (C[i+j],c[i+j-1]div 10);
C[i+j-1]:=c[i+j-1]mod 10;
End
If C[c[0]+1]>0 then Inc (C[0]);
Exit (c);
End
Begin//assign (input, ' 1.in '); reset (input);
Assign (output, ' 1.out '); rewrite (output);
READLN (s);
If s[1]= '. ' Then s:= ' 0 ' +s;
X:=pos (', s);
Bo:=0;val (Copy (S,x+1,length (s)-X), n);
For I:=1 to X-1 does if s[i]= '. ' Then bo:=i;
If Bo<>0 then bo:= (X-1-bo) *n;
While s[1]= ' 0 ' do delete (s,1,1);
Len:=x-1;
If s[1]= '. ' Then delete (s,1,1);
X:=pos (', s);
len:=x-1;bo1:=0;
For I:=1 to Len does if s[i]= '. ' Then bo1:=1;
If Bo1=1 then Dec (len); I:=len;j:=1;
A[0]:=len;
While I>=1 does begin if s[j]= '. ' Then Inc (J); A[i]:=ord (S[j])-48;
Dec (i); Inc (J);
End
Ans[0]:=1;ans[1]:=1;
For T:=1 to N do Ans:=mul (ans,a);
If BO>=ANS[0] then begin write ('. ');
For I:=1 to Bo-ans[0] do write (' 0 ');
For I:=ans[0] Downto 1 do write (Ans[i]);
End else begin for i:=1 to Ans[0]-bo do write (ans[ans[0]-i+1]);
If Bo<>0 then write ('. ');
For i:=ans[0]-i Downto 1 do write (Ans[i]);
End
Close (input); close (output);
End.
"There is a loophole in writing, welcome to pass the great God Spit trough"
2017/08/02 22:03:29
Ending.