Pagini recente » Cod sursa (job #2193929) | Cod sursa (job #2181134) | Cod sursa (job #1147748) | Cod sursa (job #2036369) | Cod sursa (job #1455895)
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#define mod 666013
using namespace std;
long long fact (long long a) {
long long ans = 1;
for (long long i = 2; i <= a; i++) {
ans = (ans * i) % mod;
}
return ans;
}
int put (int b, int e) {
int ans = 1;
while (e > 0) {
if (e % 2 == 1) {
ans = (ans * b) % mod;
}
b = (b * b) % mod;
e /= 2;
}
return ans;
}
int main() {
freopen("kperm.in", "r", stdin);
freopen("kperm.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
long long n, k;
cin >> n >> k;
if (k % 2 == 0) {
cout << 0;
return 0;
}
long long a = n % k;
long long b = n / k;
long long ans = (fact(a) * fact(k - a)) % mod;
long long f1 = fact(b);
long long f2 = (f1 * (b + 1)) % mod;
for (long long i = 0; i < a; i++) {
ans = (ans * f2) % mod;
}
for (long long i = 0; i < k - a; i++) {
ans = (ans * f1) % mod;
}
// ans = (ans * fact(a)) % mod;
//ans = (ans * fact(k - a)) % mod;
//ans = (ans * put(fact(b + 1), a)) % mod;
//ans = (ans * put(fact(b), k - a)) % mod;
cout << ans;
return 0;
}