Pagini recente » Cod sursa (job #2691577) | Cod sursa (job #1672288) | Cod sursa (job #954011) | Cod sursa (job #416261) | Cod sursa (job #2639803)
#include <bits/stdc++.h>
#define MOD 2000003
using namespace std;
ifstream fin ("sandokan.in");
ofstream fout ("sandokan.out");
int Invers (int x) {
int exp = MOD - 2, ans = 1;
while (exp) {
if (exp & 1)
ans = (1LL * ans * x) % MOD;
x = (1LL * x * x) % MOD;
exp /= 2;
}
return ans;
}
int Factorial (int n) {
if (n == 0)
return 1;
return (1LL * n * Factorial (n - 1)) % MOD;
}
int N, K;
int main () {
fin >> N >> K;
if (N <= K)
fout << "1\n";
else {
int ans = (1LL * Factorial (N - 1) * Invers (Factorial ((N - 1) % (K - 1)))) % MOD;
ans = (1LL * ans * Invers (Factorial (N - (N - 1) % (K - 1)))) % MOD;
fout << ans;
}
}