Pagini recente » Cod sursa (job #2094454) | Cod sursa (job #697927) | Cod sursa (job #2331177) | Cod sursa (job #2864049) | Cod sursa (job #26320)
Cod sursa(job #26320)
program kperm;
var n,k,r,c:longint;
h1,h2,h3,h4,h5:longint;
g:text;
procedure citire;
var f:text;
begin
assign(f,'kperm.in'); reset(f); read(f,n,k); close(f); end;
function fac(i:longint):longint;
var x:longint;
j:longint;
begin
x:=1;
for j:=1 to i do
x:=((x mod 666013)*(j mod 666013)mod 666013);
fac:=x;
end;
function put(n,m:longint):longint;
var x:longint;
i:longint;
begin
x:=1;
n:=n mod 666013;
for i:=1 to m do x:=((x mod 666013)*n)mod 666013;
put:=x;
end;
begin {pp}
citire; c:=n div k; r:=n mod k;
assign(g,'kperm.out'); rewrite(g);
if k mod 2= 0 then write(g,'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(g,h5);
end;
close(g);
end.