Cod sursa(job #1167372)

Utilizator gerd13David Gergely gerd13 Data 4 aprilie 2014 21:11:12
Problema Pascal Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1 kb
#include <fstream>

using namespace std;

const int NMAX = 5000005 ;

ifstream cin("pascal.in") ;
ofstream cout("pascal.out") ;

int R, D, first[NMAX], second[NMAX], third[NMAX];
int sol, solfirst, solsecond, solfive ;

inline void Pascal(){

for(int i = 0 ; i <= R;  ++ i)
{
    first[i] = i / 2 + first[i / 2];
    second[i] = i / 3 + second[i / 3] ;
    third[i] = i / 5 + third[i / 5] ;
}

for(int i = 0 ; i <= R; ++ i )
{
    solfirst = first[R] - first[i] - first[R - i] ;
    solsecond = second[R] - second[i] - second[R - i] ;
    solfive = third[R] - third[i] - third[R - i] ;


    if(D == 2 && solfirst)
        ++ sol ;
    if(D == 3 && solsecond)
        ++ sol ;
    if(D == 5 && solfive)
        ++ sol ;
     if(D == 4 && solfirst >= 2)
        ++ sol ;
     if(D == 6 && solfirst && solsecond)
        ++ sol ;


}

}


int main()
{
    cin >> R >> D ;
    Pascal() ;



    cout << sol << '\n';
    cin.close() ;
    cout.close() ;
    return 0;
}