Pagini recente » Cod sursa (job #1675256) | Cod sursa (job #2898180) | Cod sursa (job #1802502) | Cod sursa (job #1835034) | Cod sursa (job #26275)
Cod sursa(job #26275)
program kperm;
var n,k,r,c:integer;
h1,h2,h3,h4:int64;
procedure citire;
var f:text;
begin
assign(f,'kperm.in'); reset(f); read(f,n,k); close(f); end;
function fac(i:integer):int64;
var x:int64;
j:integer;
begin
x:=1;
for j:=1 to i do begin
x:=x*j;
if x>=666013 then repeat x:=x-666013; until x<666013;
end;
fac:=x;
end;
function put(n,m:longint):int64;
var x:int64;
i:longint;
begin
x:=1;
for i:=1 to m do begin
x:=x*n;
if x>=666013 then repeat x:=x-666013; until x<666013;
end;
put:=x;
end;
begin {pp}
citire; c:=n div k; r:=n mod k;
assign(output,'kperm.out'); rewrite(output);
if not odd(k) then write(0)
else begin
h1:=fac(r)mod 666013;
h2:=fac(k-r)mod 666013;
h3:=put(fac(c+1),r)mod 666013;
h4:=put(fac(c),k-r)mod 666013;
write((h1*h2*h3*h4)mod 666013);
end;
close(output);
end.