Pagini recente » Cod sursa (job #1569730) | Istoria paginii runda/simulare_cerc_hatz/clasament | Cod sursa (job #3174568) | Cod sursa (job #2220850) | Cod sursa (job #1782521)
#include <cstdio>
using namespace std;
short a[5000000];
int n, d;
inline int Legendre(int X, int IMP){
int Sol = 0;
long long L = IMP;
while(L <= X){
Sol = Sol + X / L;
L *= (long long) IMP;
}
return Sol;
}
int main()
{
freopen("pascal.in", "r", stdin);
freopen("pascal.out", "w", stdout);
scanf("%d%d", &n, &d);
a[0] = 1;
int Sol = 0;
for(int j = 1; j < n ; ++j){
int D2 = Legendre(n, 2) - Legendre(n - j, 2) - Legendre(j, 2);
int D3 = Legendre(n, 3) - Legendre(n - j, 3) - Legendre(j, 3);
if(d == 2){
if(D2 > 0) ++Sol;
continue ;
}
if(d == 3){
if(D3 > 0) ++Sol;
continue ;
}
if(d == 6){
if(D2 && D3) ++ Sol;
continue ;
}
}
printf("%d", Sol);
}