Cod sursa(job #3328633)
| Utilizator | Data | 9 decembrie 2025 14:15:38 | |
|---|---|---|---|
| Problema | Sandokan | Scor | 15 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <fstream>
using namespace std;
ifstream cin ("sandokan.in");
ofstream cout ("sandokan.out");
long long pow(long long x,int y)
{
long long ans=1,aux=x;
while(y){
if (y&1) ans=(ans*aux)%2000003;
aux=(aux*aux)%2000003;
y/=2;
}
return ans;
}
int main(void)
{
int n,k;
cin>>n>>k;
n--;
k--;
k%=k;
long long ans=1;
for(int i=2;i<=k;i++)
ans=(ans*i)%2000003;
for(int i=2;i<=n-k;i++)
ans=(ans*i)%2000003;
ans=pow(ans,2000001);
for(int i=2;i<=n;i++)
ans=(ans*i)%2000003;
cout<<ans<< '\n';
return 0;
}
