Pagini recente » Cod sursa (job #2109077) | Cod sursa (job #372212) | Cod sursa (job #248870) | Cod sursa (job #1034899) | Cod sursa (job #185632)
Cod sursa(job #185632)
#include <stdio.h>
int n, d, p[69], x, k, count;
void copy_paste()
{
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)
count += (p[2] >= 1);
if (d == 3)
count += (p[3] >= 1);
if (d == 4)
count += (p[2] >= 2);
if (d == 5)
count += (p[5] >= 1);
if (d == 6)
count += (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)/2-1; k++)
copy_paste();
count*=2;
if (n % 2 == 0)
copy_paste();
printf("%d\n", count);
return 0;
}