|
|
back to boardAdminse. Why my program is vrang. All seid that it is corect please help me const tabo=2000; type TArray = array [1..tabo] of integer; var n,i: longint; sol:TArray; function GetStart(op: TArray): longint; var prm: longint; begin prm:=1; while op[prm]=0 do inc(prm); GetStart:=prm; end; procedure P(var op: TArray); var nn: longint; tt: integer; buf: TArray; begin tt:=0; FillChar(buf,SizeOf(buf),0); for nn:=tabo downto GetStart(op) do begin buf[nn]:=(op[nn]*3+tt) mod 10; tt:=(op[nn]*3+tt) div 10; end; buf[nn-1]:=tt; op:=buf; end; begin Readln(n); if n>4 then begin sol[tabo]:=n-((n-2) div 3)*3; if sol[tabo]=0 then sol[tabo]:=1; for i:=1 to (n-2) div 3 do P(sol); for i:=GetStart(sol) to tabo do begin if i=tabo then Writeln(chr(ord(sol[i])+48)) else Write(chr(ord(sol[i])+48)); end; end else Writeln(n); end. |
|
|