Pagini recente » Cod sursa (job #1602282) | Cod sursa (job #1024331) | Cod sursa (job #3236182) | Cod sursa (job #2541225) | Cod sursa (job #2650082)
#include <bits/stdc++.h>
using namespace std;
ifstream in("pascal.in");
ofstream out("pascal.out");
long long gfact(long long fact, int base)
{
long long nr_div = 0;
while(fact)
{
nr_div += fact / base; fact /= base;
}
return nr_div;
}
int main()
{
long long r; int d; in >> r >> d;
long long cnt = 0;
int initial_d = d;
if(d == 6) d = 3;
if(d == 4) d = 2;
for(long long j = 0; j < r; j++)
{
if(gfact(r, d) - gfact(r-j, d) - gfact(j, d) > ((initial_d == 4) ? (1) : (0)))
cnt ++;
}
out << cnt;
}