|  | 
|  | 
| back to board | Discussion of Problem 1537. EntsI got WA#15... Because I think that my algorithm is right... 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... 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... wowsounds boring
Re: I got WA#15... Because I think that my algorithm is right... thX ACRe: I got WA#15... Because I think that my algorithm is right... Posted by Ade  21 Oct 2012 19:55What a stupid mistake I also made.
 Edited by author 21.10.2012 19:56
 | 
 | 
|