Главная » Статьи » Задачи с acm.timus.ru » Пакет решений на 15.03.08 |
1222
{W/A} Type Long = Array[0..200] of Word; Var N1,N2,I: LongInt; E: Boolean; S1,S2: Array[1..3000] of LongInt; R: Long; Procedure WriteLong(Var A: Long); Var I: Integer; S: String; Begin Write(A[A[0]]); For I:=A[0]-1 downto 1 do begin Str(A[I],S); While Length(S)<4 do S:='0'+S; Write(S); End; End; Procedure MulShort(Const A:Long;B: Word; Var R: Long); Var I: Integer; Rem: LongInt; Begin R[0]:=A[0]; Rem:=0; For I:=1 to R[0] do begin Rem:=Rem+A[I]*LongInt(B); R[I]:=Rem mod 10000; Rem:=Rem div 10000; End; R[R[0]+1]:=Rem; If (Rem<>0) then Inc(R[0]); End; Begin Read(S1[1]); N1:=1; Repeat E:=True; N2:=0; For I:=1 to N1 do If (S1[I] div 2)*(S1[I]-S1[I] div 2)>S1[I] then begin E:=False; Inc(N2,2); S2[N2-1]:=S1[I] div 2; S2[N2]:=S1[I]-S1[I] div 2; End; If not E then begin S1:=S2; N1:=N2; End; Until E; R[0]:=1; R[1]:=1; For I:=1 to N1 do MulShort(R,S1[I],R); WriteLong(R); End. | |
Категория: Пакет решений на 15.03.08 | Добавил: solver (15.03.2008) | |
Просмотров: 761 |