|  | 
|  | 
| back to board | Why I got WA? Here is my program. Program Eagle;type arr=array[1..10000]of integer;
 Var
 a:arr;
 n,m,k,l,o,p:Longint;
 Procedure check(a:arr);
 Var i:longint;
 Begin
 i:=255;
 while a[i]=0 do dec(i);
 l:=0;
 If a[i]>=4 then o:=i+1
 else o:=i;
 End;
 Procedure divided(n:longint);
 Begin
 k:=0;
 If n mod 3=0 then m:=n div 3;
 If n mod 3=1 then Begin m:=n div 3-1;k:=2;end;
 If n mod 3=2 then begin m:=n div 3;k:=1;end;
 end;
 
 Procedure timesed(m,k:longint);
 Var i,j,i1,j1,k1,l:Longint;
 Begin
 a[1]:=1;k1:=0;
 i:=0;If m>=1 then
 Repeat
 inc(i);j:=0;l:=1;
 i1:=255;while a[i1]=0 do dec(i1);
 Repeat
 inc(j);
 a[j]:=3*a[j]+k1;
 k1:=a[j] div 10;
 a[j]:=a[j] mod 10;
 inc(l);
 Until j=i1+1;
 Until i=m;
 i:=0;
 If k>=1 then
 Repeat
 inc(i);j:=0;l:=1;
 i1:=255;while a[i1]=0 do dec(i1);
 Repeat
 inc(j);
 a[j]:=2*a[j]+k1;
 k1:=a[j] div 10;
 a[j]:=a[j] mod 10;
 inc(l);
 Until j=i1+1;
 Until i=k
 end;
 
 Begin
 Readln(n);
 Fillchar(a,sizeof(a),0);
 If n<=3 then Begin
 If n=1 then write(1);
 if n=2 then write(2);
 If n=3 then write(3);
 halt;
 end;
 divided(n);
 timesed(m,k);
 o:=255;
 While a[o]=0 do dec(o);
 For p:=o downto 1 do write(a[p]);
 writeln;
 readln
 End.
 
 | 
 | 
|