Pagini recente » Cod sursa (job #69289) | Cod sursa (job #2642691) | Cod sursa (job #968258) | Cod sursa (job #84459) | Cod sursa (job #26277)
Cod sursa(job #26277)
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 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);
write((h1*h2*h3*h4)mod 666013);
end;
close(output);
end.