|
|
back to boardDiscussion of Problem 1537. EntsTry test 1 1 0 true? I also get 0. But WA15 Edited by author 03.03.2007 14:22 Edited by author 03.03.2007 14:22 Edited by author 03.03.2007 14:22 YES!!!!!!! Try this test 2 1 ))))) Thanks, AlMag! Sorry Edited by author 03.03.2007 15:44 Thanks to AlMag Why Wa 15 {$Apptype console} Const Find = 12344321; Type Longint = int64; Var a , b : array [1..10000000] of longint; N , k : longint; Function Ans(x : longint):longint; begin if b[x] = Find then begin Ans := a[x]; exit; end; b[x] := Find; if odd(x) then a[x] := Ans(x - 1) else a[x] := (Ans(x div 2) + Ans(x - 1)) mod k; Ans := a[x]; end; Begin Read(N , K); // if k = 1 then k := Trunc(1e14); b[2] := Find; a[2] := 1; if n < 2 then write(0) else Write(Ans(N)); readln; readln; end. |
|
|