Pagini recente » Cod sursa (job #1955618) | Cod sursa (job #852481) | Cod sursa (job #3266834) | Cod sursa (job #3189441) | Cod sursa (job #26282)
Cod sursa(job #26282)
program kperm;
var n,k,r,c:integer;
h1,h2,h3,h4,h5:int64;
procedure citire;
var f:text;
begin
assign(f,'kperm.in'); reset(f); read(f,n,k); close(f); end;
function fac(i:longint):int64;
var x:int64;
j:longint;
begin
x:=1;
for j:=1 to i do x:=x*j;
fac:=x mod 666013;
end;
function put(n,m:longint):int64;
var x:int64;
i:longint;
begin
x:=1;
for i:=1 to m do x:=x*n;
put:=x mod 666013;
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);
h2:=fac(k-r);
h3:=put(fac(c+1),r);
h4:=put(fac(c),k-r);
h5:=(((h1*h2)mod 666013)*((h3*h4)mod 666013))mod 666013;
write(h5);
end;
close(output);
end.