Pagini recente » Cod sursa (job #2983182) | Cod sursa (job #1307516) | Cod sursa (job #864409) | Cod sursa (job #2524403) | Cod sursa (job #1167381)
#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;
}