Pagini recente » Cod sursa (job #1727177) | Cod sursa (job #2307691) | Cod sursa (job #235351) | Cod sursa (job #2858600) | Cod sursa (job #1167358)
#include <fstream>
using namespace std;
const int NMAX = 5000005 ;
ifstream cin("pascal.in") ;
ofstream cout("pascal.out") ;
int R, D, first, second, third, pfirst, psecond, pfive, rnou, sol;
void Solving(int N, int P)
{
while(N % 2 == 0)
{
pfirst = pfirst + P ;
N = N / 2 ;
}
while(N % 3 == 0)
{
psecond =psecond + P ;
N = N / 3 ;
}
while(N % 5 == 0)
{
pfive =pfive + P ;
N = N / 5 ;
}
}
void pentru_for_funny(int k, int h)
{
Solving(k - h + 1, 1) ;
Solving(h, -1) ;
}
int main()
{
cin >> R >> D ;
//Pascal() ;
while(D % 2 == 0)
{
++ first ;
D = D / 2 ;
}
while(D % 3 == 0)
{
++ second ;
D = D / 3 ;
}
while(D % 5 == 0)
{
++ third ;
D = D / 5 ;
}
rnou = (R + 2) / 2 ; //jumate rand
for(int i = 1 ; i < rnou; ++ i)
{
pentru_for_funny(R, i) ;
sol = sol + (pfirst >= first) && (psecond >= second) && (pfive >= third) ;
}
sol <<= 1;
if(R % 2 == 0 && R)
-- sol;
cout << sol ;
cin.close() ;
cout.close() ;
return 0;
}