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

Discussion of Problem 1537. Ents

I got WA#15... Because I think that my algorithm is right...
Posted by [LG]_NAPSTER 29 Nov 2007 17:55
This is my code...

CONST
 MaxN = 10000000;

VAR
 K, P : Longint;
 A    : Array [1 .. MaxN] of Longint;

PROCEDURE Solve;
 Var
  i : Longint;
   Begin
    A[1] := 0;
    A[2] := 1;
     for i := 3 to K do
      if i mod 2 = 0 then
        A[i] := (A[i - 1] + A[i div 2]) mod P
          else
        A[i] := A[i - 1] mod P;
   End;

PROCEDURE Run;
   Begin
    ReadLn(K, P);
    Solve;
    WriteLn(A[K]);
   End;

BEGIN
  Run;
END.

Were my mistake is?

Sorry for my bad english...
Re: I got WA#15... Because I think that my algorithm is right...
Posted by Alias (Alexander Prudaev) 29 Nov 2007 20:17
A[1] := 0;
A[2] := 1; // this line is wrong, must be A[2] := 1 mod P

test
1 1
answer is 0
Re: I got WA#15... Because I think that my algorithm is right...
Posted by Miss SJC 4 Jul 2008 14:01
wow
sounds boring
Re: I got WA#15... Because I think that my algorithm is right...
Posted by [LG]_#\#@P$T[101]R 4 Jul 2008 15:25
thX AC
Re: I got WA#15... Because I think that my algorithm is right...
Posted by Ade 21 Oct 2012 19:55
What a stupid mistake I also made.

Edited by author 21.10.2012 19:56