Cod sursa(job #2827942)
| Utilizator | Data | 6 ianuarie 2022 17:05:37 | |
|---|---|---|---|
| Problema | Kperm | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.61 kb |
#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;
}
return 0;
}
