var x: qword; y: longint; begin x := 1<<64-1; y := 100; x := x mod y; //报错201 x := x mod qword(y); //正确 end.
Code
var a,b: qword; _, n, i, k, cnt: longint; f: array [1..1000000] of longint;
functionsuperMod(a, b: qword; m: longint): longint; var x: qword; begin if b = 0then exit(1); x := superMod(a, b shr1, m); superMod := x * x mod m; if odd(b) then superMod := superMod * a mod m; end;
begin assign(input, 'main.in'); reset(input); assign(output, 'main.out'); rewrite(output); readln(_); while _ > 0do begin dec(_); readln(a, b, n); if a = 0then begin writeln(0); continue; end; if n = 1then begin writeln(0); continue; end; f[1] := 1; f[2] := 1; cnt := 2; whilenot ((f[cnt-1] = 1) and (f[cnt] = 0)) do begin inc(cnt); f[cnt] := (f[cnt-1] + f[cnt-2]) mod n; end; //while x > int64(1 <<60) do // x := x - int64((cnt << 59)); a := a mod qword(cnt); k := superMod(a, b, cnt); writeln(f[k]); end; close(output); close(input); end.
OOPS!
A comment box should be right here...But it was gone due to network issues :-(If you want to leave comments, make sure you have access to disqus.com.