Pagini recente » Cod sursa (job #1190337) | Cod sursa (job #442878) | Cod sursa (job #175618) | Cod sursa (job #791393) | Cod sursa (job #447074)
Cod sursa(job #447074)
#include <cstdio>
int N, D, p[70], x, K, rez;
void solve()
{
x = N - K;
while (x % 2 == 0)
x /= 2, p[2]++;
while (x % 3 == 0)
x /= 3, p[3]++;
while (x % 5 == 0)
x /= 5, p[5]++;
x = K + 1;
while (x % 2 == 0)
x /= 2, p[2]--;
while (x % 3 == 0)
x /= 3, p[3]--;
while (x % 5 == 0)
x /= 5, p[5]--;
if (D == 2)
rez += (p[2] >= 1);
if (D == 3)
rez += (p[3] >= 1);
if (D == 4)
rez += (p[2] >= 2);
if (D == 5)
rez += (p[5] >= 1);
if (D == 6)
rez += (p[2] >= 1 && p[3] >= 1);
}
int main()
{
freopen("pascal.in", "r", stdin);
freopen("pascal.out", "w", stdout);
scanf("%d%d", &N, &D);
for (K = 0; K < ((N + 1) >> 1) - 1; K++)
solve();
rez *= 2;
if (N % 2 == 0)
solve();
printf("%d\n", rez);
return 0;
}