Pagini recente » Cod sursa (job #218990) | Cod sursa (job #1708382) | Cod sursa (job #229322) | Cod sursa (job #2479439) | Cod sursa (job #2827938)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin ("kperm.in");
ofstream fout ("kperm.out");
const int MOD=666013;
const int NMAX=5005;
int f[NMAX];
int main()
{
int n,k,a,b,kper,i,j;
fin>>n>>k;
if(k%2==0)
{
fout<<0;
}
else
{
f[0]=1;
for(int i=1;i<=n;i++)
f[i]=(1LL*f[i-1]*i%MOD);
a=n%k;
b=k-n%k;
kper=1LL*f[a]*f[b]%MOD;
for(i=1;i<=a;i++)
kper=(1LL*kper*f[n/k+1]%MOD);
for(i=1;i<=b;i++)
kper=(1LL*(kper*f[n/k])%MOD);
fout<<kper%MOD;
}
return 0;
}