Cod sursa(job #2839228)

Utilizator MihaiCostacheCostache Mihai MihaiCostache Data 25 ianuarie 2022 16:24:36
Problema Sandokan Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <fstream>
#define mod 2000003
using namespace std;
ifstream fin("sandokan.in");
ofstream fout("sandokan.out");
int n, k, x, v[5001], c[5001];
int main()
{
    fin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        fin>>x;
    }
    int p=(n-1)%(k-1)+1;
    v[0]=v[1]=c[0]=1;
    for(int i=2; i<n; i++)
    {
        for(int j=1; j<=i; j++)
        {
            c[j]=(v[j]+v[j-1])%mod;
        }
        for(int j=1; j<=i; j++)
        {
            v[j]=c[j];
        }
    }
    fout<<c[p-1];
    return 0;
}