Pagini recente » Atasamentele paginii Profil Tudor_Tape | Cod sursa (job #3314907) | Cod sursa (job #851464) | Borderou de evaluare (job #1526906) | Cod sursa (job #3328896)
#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;
}
int main()
{
init_fact();
cin >> n >> k;
--k;
int j; for (int i = 1; i <= n; ++i) cin >> j;
/// x = nr. de numere ramase la final
int x = 0;
while (x <= n){
x += k;
}
x -= k;
cout << (1LL * fact[n] * fast_expo((1LL * fact[x] * fact[n - x]) % MOD, MOD - 2)) % MOD;
cout << ' ' << x;
return 0;
}