Cod sursa(job #3251201)

Utilizator marap2011Paun Mara marap2011 Data 25 octombrie 2024 12:57:12
Problema Pascal Scor 10
Compilator cpp-64 Status done
Runda cex_1 Marime 0.67 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("pascal.in") ;
ofstream fout ("pascal.out") ;
int l , c ;
static inline void citire ()
{
    fin >> l >> c ;
}
int fact ( int x )
{
    int prod = 1 ;
    for ( int i = 1 ; i <= x ; i ++ )
        prod = ( ( prod % c ) * ( i % c ) ) % c ;
    return prod ;
}
static inline void rezolvare ()
{
    int i = fact(l) , r = 0 ;
    for ( int j = 1 ; j <= l ; j ++ )
    {
        int nr = ( ( i % c ) / ( ( ( fact( abs ( i - j ) ) % c ) * ( fact( j ) % c ) ) % c ) ) % c ;
        if ( nr == 0 )
            r ++ ;
    }
    fout << r ;
}
int main()
{
    citire() ;
    rezolvare() ;

    return 0;
}