ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

P1222. WA. Help
Posted by I am david. Tabo. 29 Oct 2002 22:46
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.
I think you program is correct...
Posted by Algorithmus_UA(algorithmus@univ.kiev.ua) 30 Oct 2002 14:52
I tested it, but all test is OK. Maybe someting wrong in TIMUS
compiler? I have analog problem with K-based numbers version 2&3. Try
contact with admins.