Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

用pascal怎么做啊,老是超时,好要不要命啊!!顺便解决了~

Posted by XiLanglang at 2012-08-11 15:09:37 on Problem 2083
var
        n,i,j,k:longint;
        f:array[0..1000,0..1000] of char;
procedure draw(x,y,n:longint);
var
        k,i:longint;
begin
        if n=1 then f[x,y]:='X'
        else begin
                k:=1;
                for i:=1 to (n-1) do k:=k*3;
                k:=k div 3;
                draw(x,y,n-1);
                draw(x,k*2+y,n-1);
                draw(k+x,k+y,n-1);
                draw(k*2+x,y,n-1);
                draw(k*2+x,k*2+y,n-1);
        end;
end;
begin
        while not eof do begin
                readln(n);
                fillchar(f,sizeof(f),' ');
                draw(1,1,n);
                k:=1;
                for i:=1 to (n-1) do k:=k*3;
                for i:=1 to k do begin
                        for j:=1 to k do begin
                                write(f[i,j]);
                        end;
                        writeln;
                end;
                writeln('-');
        end;
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator