Pagini recente » Cod sursa (job #1721998) | Cod sursa (job #2028299) | Cod sursa (job #2376262) | Cod sursa (job #2445214) | Cod sursa (job #827328)
Cod sursa(job #827328)
#include <cstdio>
using namespace std;
int N, Factor[3] = {2, 3, 5}, DPower[3], Solution;
int Pow[3];
inline int GetPower(int X, const int factor) {
int power = 0;
for (; X % factor == 0; ++power, X /= factor);
return power;
}
inline int IsDivisible(const int k) {
int divisible = 1;
for (int i = 0; i < 3; ++i) {
Pow[i] += GetPower(N - k + 1, Factor[i]) - GetPower(k, Factor[i]);
if (Pow[i] < DPower[i])
divisible = 0;
}
return divisible;
}
void Solve() {
for (int k = 1; k < N / 2; ++k)
Solution += IsDivisible(k);
Solution *= 2;
if (N % 2 == 0)
Solution += IsDivisible(N / 2);
}
void Read() {
freopen("pascal.in", "r", stdin);
int D; scanf("%d %d", &N, &D);
for (int i = 0; i < 3; ++i)
for (; D % Factor[i] == 0; ++DPower[i], D /= Factor[i]);
}
void Print() {
freopen("pascal.out", "w", stdout);
printf("%d\n", Solution);
}
int main() {
Read();
Solve();
Print();
return 0;
}