Cod sursa(job #2911695)

Utilizator AnaGrigorieAna Teodora Grigorie AnaGrigorie Data 1 iulie 2022 12:34:26
Problema Pascal Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <fstream>

using namespace std;
ifstream fin("pascal.in");
ofstream fout("pascal.out");
int nr,d,n;
long long int a[5000001][5000001];
int main()
{
    fin>>n>>d;
    for(int i=1;i<=n+1;i++)
    {

        for(int j=1;j<=n+1;j++)
        {
            if(j==1 || i==j)
            {
                a[i][j]=1;
            }
            else
            {
                a[i][j]=a[i-1][j-1]+a[i-1][j];
            }
            //fout<<a[i][j]<<" ";
        }
        //fout<<"\n";
    }
    for(int j=1;j<=n+1;j++)
    {
        if(a[n+1][j]%d==0)
        {
            nr++;
        }
    }
    fout<<nr;
    return 0;
}