Pagini recente » Cod sursa (job #2865908) | Cod sursa (job #670438) | Cod sursa (job #844273) | Cod sursa (job #2589279) | Cod sursa (job #64049)
Cod sursa(job #64049)
/*
SRM 230 DIV 1 500 points
*/
#include <cstdio>
using namespace std;
int ret;
int f2[5000001], f3[5000001], f5[5000001];
int d[10];
int main( ) {
freopen("pascal.in", "r", stdin);
freopen("pascal.out", "w", stdout);
int I, d;
scanf("%d %d", &I, &d);
int i, j, k, l;
for (i = 2; i <= I ; i+=2) f2[i]= f2[i / 2] + 1;
for (i = 3; i <= I; i+=3) f3[i] = f3[i/3] + 1;
for (i = 5; i <= I; i+=5) f5[i] = f5[i/5] + 1;
for (i = 1; i<= I; ++i) f2[i]+=f2[i-1], f3[i]+=f3[i-1], f5[i]+=f5[i-1];
for (j = 0; j <=I; ++j) {
int t2 = f2[I], t3 = f3[I], t5 = f5[I];
t2-= f2[j]; t3 -= f3[j]; t5 -= f5[j];
t2-= f2[I -j]; t3 -= f3[I - j] ; t5 -= f5[I - j];
if (d == 2 && t2 ) ret++;
if (d ==3 && t3) ret++;
if (d == 4 && t2 >= 2) ret++;
if (d ==5 && t5) ret++;
if (d == 6 && t2 && t3 ) ret++;
}
pritnf("%d\n", ret);
return 0;
}