Pagini recente » Cod sursa (job #3335142) | Cod sursa (job #3348988) | Monitorul de evaluare | Cod sursa (job #3310752) | Cod sursa (job #3328897)
#include <fstream>
#define MOD 2000003
using namespace std;
ifstream cin ("sandokan.in");
ofstream cout ("sandokan.out");
int fact[5005];
int n, k;
void init_fact (){
fact[1] = fact[0] = 1;
for (int i = 2; i <= 5000; ++i){
fact[i] = (1LL * fact[i - 1] * i) % MOD;
}
}
int fast_expo (int b, int e){
int x = 1;
while (e){
if (e % 2 == 1){
x = (x * b) % MOD;
}
b = (b * b) % MOD;
e /= 2;
}
return x % MOD;
}
int main()
{
init_fact();
cin >> n >> k;
--k;
int j; for (int i = 1; i <= n; ++i) cin >> j;
int x = 0;
while (x <= n){
x += k;
}
x -= k;
long long sol = fact[n];
sol = (1LL * sol * fast_expo(fact[x], MOD - 2) % MOD) % MOD;
sol = (1LL * sol * fast_expo(fact[n - x], MOD - 2) % MOD) % MOD;
cout << sol;
// cout << ' ' << x;
return 0;
}