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

Please see my program!!It runs in my home well.Why it always gets 'Crash(ACCESS_VIOLATION)'(Problem 1108)
Posted by Lin 27 Oct 2001 17:44
Const Max=27000;

Var A,C         : Array[1..Max] of Byte;
    N           : Integer;
    i,j,k       : Integer;
    Last        : Integer;
    First       : Integer;
    L           : Integer;
    P           : Longint;
    P1          : Integer;

Begin
  Readln(N);
  If N>18 then Exit;
  A[1] := 1;
  For i := 1 to N-1 do
    Begin

      Fillchar(C,Sizeof(C),0);
      For L := Max downto 1 do
        If A[L]<>0 then Break;

      C := A;

      For j := 1 to L*2-1 do
        Begin
          Last := (j+1) Div 2;
          If (j+1) Mod 2=0 then
            Begin
              Inc(P,A[(j+1) div 2]*A[(j+1) Div 2]);
              Dec(Last);
            End;
          If j<=L then First := 1
                  else First := j-L;
          For k := First to Last do
            Inc(P,A[k]*A[j+1-k]*2);
          Inc(P,C[j]); C[j] := P Mod 10;
          P := P Div 10;
        End;
      P1 := L*2-1;
      While P<>0 do
        Begin
          Inc(P1);
          P := C[P1]+P;
          C[P1] := P Mod 10;
          P := P Div 10;
        End;

      P := 1; P1 := 1;
      Repeat
        P := P+A[P1];
        A[P1] := P Mod 10;
        P := P Div 10;
      Until P=0;

      For j := Max downto 1 do
        If A[j]<>0 then Break;
      For k := j downto 1 do
        Write(A[k]);
      Writeln;
      A := C;
    End;
      P := 1; P1 := 1;
      Repeat
        P := P+A[P1];
        A[P1] := P Mod 10;
        P := P Div 10;
      Until P=0;

  For L := Max downto 1 do
    If A[L]<>0 then Break;
  Writeln(L);
  For j := L downto 1 do
    Write(A[j]);
End.
Re: Please see my program!!It runs in my home well.Why it always gets 'Crash(ACCESS_VIOLATION)'(Problem 1108)
Posted by Li, Yi 28 Oct 2001 05:56
Change Max into 270000
> Const Max=27000;
>
> Var A,C         : Array[1..Max] of Byte;
>     N           : Integer;
>     i,j,k       : Integer;
>     Last        : Integer;
>     First       : Integer;
>     L           : Integer;
>     P           : Longint;
>     P1          : Integer;
>
> Begin
>   Readln(N);
>   If N>18 then Exit;
>   A[1] := 1;
>   For i := 1 to N-1 do
>     Begin
>
>       Fillchar(C,Sizeof(C),0);
>       For L := Max downto 1 do
>         If A[L]<>0 then Break;
>
>       C := A;
>
>       For j := 1 to L*2-1 do
>         Begin
>           Last := (j+1) Div 2;
>           If (j+1) Mod 2=0 then
>             Begin
>               Inc(P,A[(j+1) div 2]*A[(j+1) Div 2]);
>               Dec(Last);
>             End;
>           If j<=L then First := 1
>                   else First := j-L;
>           For k := First to Last do
>             Inc(P,A[k]*A[j+1-k]*2);
>           Inc(P,C[j]); C[j] := P Mod 10;
>           P := P Div 10;
>         End;
>       P1 := L*2-1;
>       While P<>0 do
>         Begin
>           Inc(P1);
>           P := C[P1]+P;
>           C[P1] := P Mod 10;
>           P := P Div 10;
>         End;
>
>       P := 1; P1 := 1;
>       Repeat
>         P := P+A[P1];
>         A[P1] := P Mod 10;
>         P := P Div 10;
>       Until P=0;
>
>       For j := Max downto 1 do
>         If A[j]<>0 then Break;
>       For k := j downto 1 do
>         Write(A[k]);
>       Writeln;
>       A := C;
>     End;
>       P := 1; P1 := 1;
>       Repeat
>         P := P+A[P1];
>         A[P1] := P Mod 10;
>         P := P Div 10;
>       Until P=0;
>
>   For L := Max downto 1 do
>     If A[L]<>0 then Break;
>   Writeln(L);
>   For j := L downto 1 do
>     Write(A[j]);
> End.
>