Cod sursa(job #2346177)
Utilizator | Data | 17 februarie 2019 12:41:13 | |
---|---|---|---|
Problema | Sandokan | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("sandokan.in");
ofstream fout("sandokan.out");
int n,k;
int v[100001];
int main()
{
fin>>n>>k;
n--;k--;
if(k-1==0)
{
fout<<1;
return 0;
}
v[0]=v[1]=1;
for(int i=2;i<=n;i++)
for(int j=i;j>=1;j--)
{
v[j]=v[j]+v[j-1];
if(v[j]>2000003)
v[j]-=2000003;
}
fout<<v[n%k];
return 0;
}