Pagini recente » Cod sursa (job #1369175) | Cod sursa (job #310840) | Cod sursa (job #353987) | Cod sursa (job #1568943) | Cod sursa (job #1561246)
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <fstream>
#define MAX_N 5000010
using namespace std;
int divs[7] = {0, 0, 2, 3, 2, 5, 2};
int mapPrimeFact[7] = {-1, -1, 0, 1, 0, 2, 0};
int primeFact[3] = {2, 3, 5};
int n, d, apar, apar2;
char nPut[3][MAX_N];
int addMult(int x, int sign) {
apar += sign * nPut[mapPrimeFact[d]][x];
if (d == 6)
apar2 += sign * nPut[1][x];
}
int main() {
ifstream cin("pascal.in");
freopen("pascal.out", "w", stdout);
cin >> n >> d;
for (int i = 1; i <= n; i++)
for (int j = 0; j < 3; j++)
if (i % primeFact[j] == 0)
nPut[j][i] = nPut[j][i / primeFact[j]] + 1;
int sol = 0;
for (int i = 1, j = n; j; i++, j--) {
addMult(j, 1);
addMult(i, -1);
if (d == 4)
sol += (apar > 1);
else if (d == 6)
sol += (apar && apar2);
else sol += (bool) apar;
}
printf("%d\n", sol);
return 0;
}